Linux – Run Script on logout/ shutdown ubuntu

gnomelinuxlogoutUbuntu

I want to run some commands every time a user of an ubuntu 9.10 machine logs out or shuts down. What is the best way to do this? Every user uses gnome if that helps.

Best Answer

After some Googling I found How to run a script on logout? which says to add the script to $HOME/.bash_logout.

If that doesn't work, add

$HOME/.bash_logout

to /etc/gdm/PostSession/Default so it executes the logout script properly.

Seeing as before shutdown the user is logged off anyway, this should cover both bases.

Related Question