LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices

Reply
 
Search this Thread
Old 04-07-2013, 05:53 AM   #1
P5music
Member
 
Registered: Nov 2010
Posts: 59

Rep: Reputation: 0
FC18: running a command on shutdown (or reboot) before every other shutdown operation


Hello,
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
 
Old 04-22-2013, 02:21 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,147

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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.
 
Old 04-22-2013, 02:28 PM   #3
P5music
Member
 
Registered: Nov 2010
Posts: 59

Original Poster
Rep: Reputation: 0
I use the Gnome version.
 
Old 04-23-2013, 03:56 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,147

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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:
Code:
$ cat /usr/local/bin/shutdown 
#!/bin/bash
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Reboot/shutdown command without sudo eveningsky339 Debian 4 03-11-2011 08:34 AM
Fighting with making running a script at startup only but not at shutdown/reboot ... Xeratul Debian 5 12-01-2010 01:13 PM
Unable to shutdown/reboot server, no shutdown process running dctw Linux - Server 5 03-31-2010 05:46 AM
[FYI] "last -f <old wtmp> -x reboot shutdown" incorrect for last reboot and shutdown catkin Linux - General 1 03-25-2010 11:52 PM
run this command when the computer shutdown or reboot lindylex Debian 4 11-25-2008 04:31 PM


All times are GMT -5. The time now is 03:43 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration