Run script when shutting down Ubuntu before the logged in user is logged out

3

1

I'm writing a script to backup some local directories on a Unix machine (Ubuntu) to a Samba drive. The script works fine and I've got it running at shutdown and restart using the method described at [Ubuntu] Executing a script at startup and shutdown.

It works by placing the backup script into the /etc/rc6.d and /etc/rc0.d directories.

However there is a problem. After looking at the scripts logfile it seems to be run after the user is logged out. We are using LDAP authentication and when the user logs out, the system cannot backup to their Samba share.

Does anyone know of anyway to run the script before the user is logged out?

Travis

Posted 2012-10-26T10:01:46.400

Reputation: 413

Answers

0

The easy way I see this to accomplish is to put the command to call your script to ~/.bash_logout

Alexander Shcheblikin

Posted 2012-10-26T10:01:46.400

Reputation: 620