On Tue, Apr 05, 2011 at 11:57:31AM +0800, waterloo wrote:
> How to run a command as root when I shutdown system automatically ?
> I use Debian 6 amd64.
Searching online led me to this:
http://synapse.wordpress.com/2007/03/24/run-a-script-on-startup-shutdown-in-linux/
HTH.
Kumar
Off the top of my head (and requires debugging)
#!/usr/bin/env (ba)sh # (your choice of bash or sh)
execute-your-cmd-here
shutdown -r now # swap -r for -h if you wish to halt instead of reboot
inversely you can 'man (or info) bash' and learn how to use case so you can pass switches to your script ... i.e.
/root/bin/your-shutdown-script -r
or
/root/bin/your-shutdown-script -h
If given enough inclination, I might be able to write something in python (albeit it crude and rudimentary but it should get the job done)
--
Did you know...
If you play a Windows 2000 CD backwards, you hear satanic messages,
but what's worse is when you play it forward....
...it installs Windows 2000