Sunday, February 7, 2010

Running Scripts on Shutdown and Startup

Running Script at time of shutdown
=========================

myscript:

#!/bin/sh
echo `date`>>/home/vamshi/Desktop/vvvshut.txt
exit 0

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

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

chmod +x file.sh

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

0 comments:

Post a Comment