GDM scripts not executing

Hello everyone!

I am trying to set up a script that runs in a host and is executed when the user logs out. To do this, I want to use the /etc/gdm/PostSession/Default script. The script is very simple, just for testing purposes:

#!/usr/bin/bash
LOG=/var/log/test.log

for i in {1..10};
do
   echo "> Iteration: $i ..." >> $LOG
   sleep 1
done

exit 0

The idea is to monitor the log file from putty to check that the script is running correctly que the user logs out, but the reality is that it is not running.

I tested with the scripts /etc/gdm/*/Default, but they are not running either.

I’m running Rocky 8.8 and GNOME 3.32

Any hint? thanks in advance

Permissions?

chmod 755 Default

Hi!

I´m afraid is not a permission issue (already checked). Besides, gdm user runs with root rights…

Does loginctl and/or logs (journalctl, /var/log) show that the session has ended?
I’ve seen a lot of sessions that hang in “Closing” state forever (due to some process that does not die).

I believe the session has ended, or at least the logout process initialization is captured because of these lines of journalctl output:

pam_unix(gdm-password:session): session closed for user <user_identifier>
...
systemd-logind[1654]: Session 367 logged out. Waiting for processes to exit.

I guess GDM post-session script should run when this event is identified, but it is not.

Check with loginctl, because I have:

# loginctl session-status 2
2 - xyz (*)
           Since: Wed 2023-06-14 14:10:38 EEST; 2 months 7 days ago
          Leader: 1399
            Seat: seat0; vc1
         Display: :0
         Service: lightdm; type x11; class user
         Desktop: mate
           State: closing
            Unit: session-2.scope
                  └─1766 /usr/libexec/geoclue-2.0/demos/agent
...
Jun 14 14:31:38 myhost lightdm[1399]: pam_unix(lightdm:session): session closed for user xyz
#
# journalctl | grep "logind.*Session 2 "
Jun 14 14:31:38 myhost systemd-logind[942]: Session 2 logged out. Waiting for processes to exit.

It does look like that session is still waiting for processes to exit (two months down the road).
(Granted, that is lightdm and not gdm.)


In fact, “clean exit” has also message about removal:

Jul 13 14:19:46 myhost systemd-logind[942]: Session 29 logged out. Waiting for processes to exit.
Jul 13 14:19:46 myhost systemd-logind[942]: Removed session 29.

The systemd waiting might be a red herring; there are no lingering dm processes on these “zombies”.