-   Linux - Newbie (
-   -   setting script to run when system enter init 3 (

fowlerlfc 10-29-2002 01:32 PM

setting script to run when system enter init 3
I'ver written a little script that starts several services. I would like this script to run whenever the system goes into runlevel 3. How do I set this up? and would I need to write a script that gracefully shuts down these services when the machine shutsdown?

Any help is greatly appreciated!

mirkokl 10-29-2002 01:55 PM

First, check whether the scripts already exist. Normally they are located at /etc/init.d. Some distros use a central configuration file for activating services at boot time.

If not, create new scripts, best one script per service. Use the scripts of your distro, copy and modify them. They aren't just start scripts, but also stop or display the status, you use them by entering: /etc/init.d/example start
/etc/int.d/example stop

Now look for the subdirectories. Search for a script which is started on entring runlevel 3 and stopped on rl 1. Look for the according scripts in rc3.d and rc1.d.

You ought to find a copy of the script in rc3.d and in rc1.d or a symbolic link. These have the name S??example and K??example. S... is used for starting when entering the runlevel and K... for stopping. Check this and ask if anything stays unclear, as your computer might hang on boot or shutdown when you make a mistake.

Enter the links for your script, as said, if they aren't already there.

adam_boz 10-29-2002 03:02 PM

... and make sure it's execable. If you don't want to deal w/ linking it, you can just put it in /etc/rc.d/rc3.d/ as
S##<name> . You don't really need to add all that start-stop stuff, it can be as simple as:

mke2fs /dev/hda1

hehe... just kidding (but it can be that simple)

All times are GMT -5. The time now is 01:55 PM.