change startup priority of services


I am using Red hat Enterprise Linux AS release 3.

I have 3 custom services : service_1, service_2 and service_3. Now i want these services startup in order:
when the system startup.

What should I do now?


Who is Participating?
On RHEL, you shouldn't manually change the Snn number of a script. You should use chkconfig to change the priority of the script.

In the top of each script, you should have something like the following:

# Init file for OpenSSH server daemon
# chkconfig: 2345 55 25
# description: OpenSSH server daemon

The line you are interested in is the chkconfig: line.

The first group of numbers after the chkconfig: are the runlevels that the script will be called in. The following two groups of numbers are the startup order and shutdown order. So in this example, SSH will be started about midway through the init process (55) and shutdown around a quarter of the way through the shutdown process (25)

First, stop the service and remove it from chkconfig by doing
chkconfig --del  service_1

After changing the startup numbers, re-add the script and set it to start at boot time by doing
chkconfig --add service_1
chkconfig service_1 on

If your services are service_1, service_2 and service_3, and you set them to 99 01 (start last, end first), then they will be started in the right order. This is because the startup system first gets the number (99) and if it finds more than 1 script at 99, starts the scripts in alphabetical order.

This won't help you if your services are named something like foo, bar, grr - in this case, bar would start before foo. The solution here would be to set bar to foo to 97, bar to 98 and grr to 99

Hope that helps
what you should do now is to have a look to this link:
init is clever enough to start services in the correct order,1

use runlevel to find put in what runlevel are you using. Assume that you are using level 2 so than go to /etc/rc2.d and play with numbers of your scripts.

hope this helps

You can simply setup dependency on these service. So these services startup before others
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.