Linux.com

Home Linux Community Forums Linux Distributions Fedora Starting and stopping the script

Starting and stopping the script

Link to this post 18 Feb 11

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

Link to this post 18 Feb 11

Look closer at the documentation here: /usr/share/doc/initscripts-[VERSION]/sysvinitfiles

Since I don't know your initscripts version, this command should work:

# less /usr/share/doc/initscripts*/sysvinitfiles

And my guess is there are some tags missing in your script, according to the sysvinitfiles file:


# chkconfig: <startlevellist> <startpriority> <endpriority>

Required. <startlevellist> is a list of levels in which
the service should be started by default. <startpriority>
and <endpriority> are priority numbers. For example:
# chkconfig: 2345 20 80
Read 'man chkconfig' for more information.

Unless there is a VERY GOOD, EXPLICIT reason to the
contrary, the <endpriority> should be equal to
100 - <startpriority>

# description: <multi-line description of service>

Required. Several lines of description, continued with '\'
characters. The initial comment and following whitespace
on the following lines is ignored.

You can also look at existing init script tags, for example:

# head -n30 /etc/init.d/sshd

Link to this post 19 Feb 11

Thanks for your reply.

Yes that was really helpful,

I use the chkconfig command and this time i assign priorities

chkconfig --level 2345 testscript on 99 00

and now it also work for shutdown and reboot.


Thank you :)

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board