Sunday, February 7, 2010

Running Scripts on Shutdown and Startup

Running Script at time of shutdown


echo `date`>>/home/vamshi/Desktop/vvvshut.txt
exit 0

the script should begin with #!/bin/sh called as "shebang" line

file is saved as
  • in /etc/init.d/
  • in /etc/rc0.d/
  • in /etc/rc6.d/
then executable permissions are given in all directories with command

chmod +x

that's it, Script executes on shutdown.

Running Script at time of startup

Script is same, but now i need to execute at startup and may be write to a different file about the startup time.

For this just put that script in /etc/rc.local file.

This file will execute at the time of startup and make that script
run for you


Post a Comment