February 18, 2011

Starting and stopping the script

Forums: 

Hello,

i have this simple script.

set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin

case "$1" in
start)
echo "Startup of testscript. Tid: `date`" >> /var/testofstartup
;;
stop)
echo "Stop of testscript. Tid: `date`" >> /var/testofstartup
;;
force-reload|restart)
$0 stop
$0 start
;;
status)
echo "All is well"
;;
*)
echo "Usage: /etc/init.d/atd {start|stop|restart|force-reload|status}"
exit 1
;;
esac

exit 0

Now i copied this script into the /etc/init.d and chmod 755 to it.

Then i made the following links

ln -s /etc/init.d/testscript /etc/rc5.d/S22testscript
ln -s /etc/init.d/testscript /etc/rc0.d/K22testscript

After that i do the chkconfig --add testscript and chkconfig --level 5 on

Then now what happenning is that the script automatically start as Fedora 13 boots but don't stop and it shutdown (i see the script status in the /var/testforstartup as defined in the bash code)

I have googled around for this then i even try for stopping the script at shutdown using.

ln -s /etc/init.d/testscript /etc/rc6.d/K22testscript

but still noting happens.

I am really confused , already like shutdown and reboot my machine 50 times and this dont work

Please help.

Thanks

usmangt