-   Fedora (
-   -   FC18: running a command on shutdown (or reboot) before every other shutdown operation (

P5music 04-07-2013 05:53 AM

FC18: running a command on shutdown (or reboot) before every other shutdown operation
I would like to execute a command when I shutdown or reboot my Fedora 18 system. I think I have to put the command in a shutdown script but my goal is that the command is executed as soon as possible, that is, very after I choose to shutdown/reboot the system.
Thanks in advance

PTrenholme 04-22-2013 02:21 PM

You don't specify which desktop manager you're using, so this may not help you. :)

If you're using KDE, go to the system settings menu, select "Startup and Shutdown" from the "System Administration" menu. Add the script(s) you want run, and select "shutdown" from the pulldown "Run On" box.

There may be a similar setting for GNOME, but I don't use GNOME very much.

P5music 04-22-2013 02:28 PM

I use the Gnome version.

PTrenholme 04-23-2013 03:56 PM

O.K., I booted GNOME and searched for some way to accomplish this, but couldn't find any. (The closest I got was the gnome-session-properties command that lets you change the startup scripts, and save your session when you log out so any program(s) you had running will be restarted.

Have you tried writing a shutdown script that replaces the /sbin/shutdown command? Something like this:

$ cat /usr/local/bin/shutdown
sudo umount --all --force --type cifs
exec sudo /sbin/shutdown $*

which I wrote when my system was hanging during shutdown waiting for the Window$ system to respond to an umount command. (I had originally changed the symlink of shutdown in /sbin to point to that script, but often when systemd gets updated, the symlink is reset.)

Note that I have "Unbuntized" my sudo so I don't need to enter a password. (Not recommended for any system needing security.)

I haven't actually tried that script under GNOME, but it, or something like it, might work for you.

All times are GMT -5. The time now is 07:28 AM.