change startup priority of services

Posted on 2006-05-11
Last Modified: 2013-12-06

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?


Question by:freshrain
    LVL 10

    Expert Comment

    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

    LVL 5

    Accepted Solution

    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

    Expert Comment

    You can simply setup dependency on these service. So these services startup before others

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now