Click to See Complete Forum and Search --> : How to run a perlscript during boot up


Notfromkansas
11-06-2001, 02:25 PM
I have a perlscript which I wish to run at boot up. I have have tried to put it in rc5.d and rc4.d but it just will not run. It is not the perlscript itself that does not work since I can run it manually in a terminal with "perl perlstart".

I hope someone can help me :)

EyesWideOpen
11-06-2001, 05:22 PM
I believe that if you make a link to your script from within the rcrunlevel.d (rc5.d if your runlevel is 5) directory and name the link something like S99perlstart (and assuming your script is executable) then that should work for you. Or is that what you already tried to do?

In case you didn't know, you can find you runlevel by looking in your /etc/inittab file for a line similar to this:
id:5:initdefault:

Five is the runlevel in the example above.

stiles
11-06-2001, 06:28 PM
I'm not sure if that will work or not. I believe that init expects a shell script in /etc/init.d/<script_name> (or however your distro lays out init) which is linked from your runlevel.

I'd write a little start|stop|restart script and call your perl script from there. Something like this:


#!/bin/sh
NAME=<replace_with_service_name>
case "$1" in
start)
echo -n "Start Message "
<add command to start service>
echo "Done" ;;
stop) echo -n "Stop Message "
<add command to stop service>
echo "Done" ;;
restart) echo -n "Restart Message "
<add commands to stop/start service>
echo "Done" ;;
*) echo "Usage: /etc/init.d/$NAME {start|stop|reload}" exit 1 ;;
esac
exit 0

Notfromkansas
11-08-2001, 09:35 AM
Thank you all for your help.

This is what I did: I made a bash script, which starts the perl script. Named it S99something and put it in etc/rc5.d.

It works perfectly.

Furthermore, what does S99 and all the other beginnings of the filenames in rc.5d stand for?
:)