[CentOS] # chkconfig: kill at run level 3

Sat Dec 4 15:25:47 UTC 2010
Keith Roberts <keith at karsites.net>

On Sat, 4 Dec 2010, Michael D. Berger wrote:

> To: centos at centos.org
> From: Michael D. Berger <m_d_berger_1900 at yahoo.com>
> Subject: [CentOS] # chkconfig: kill at run level 3
> In the control script of my daemon in /etc/init.d?, I have
>   # chkconfig: 35 97 3
> The result of this is that I have links:
>   /etc/rc.d/rc1.d/K03...
>   /etc/rc.d/rc3.d/S97...
>   /etc/rc.d/rc5.d/S97...
> As mentioned in a previous thread, my complex daemon throws
> an exception when I shutdown.  Perhaps things might be better
> if I had:
>   /etc/rc.d/rc3.d/K03...
> Might this be a good idea?  If so, how can I make it happen
> automatically?

What I would suggest is using mc file/directory browser:

cd to /etc/init.d/

create a directory called tmp-backups

make a copy of all the init scripts in above directory

Working in /etc/init.d/ find the start/stop script that's 
giving you problems.

Copy it to another filename, eg (your-initials)-scriptname

(That way any init scripts you add will all be in one place, 
starting with your initials) and easy to find.

Gut the new script, and use it as a skeleton to create your 
own init start/stop script.

Decide what you want the script to do at start time, and 
at stop time.

Alter the parameters for when the script starts and stops, 
at the top of the file.

Make this script run at shutdown before the main script you 
copied it from.

You might need to add a shell conditional to prevent the 
script from shutting down your app straight away at boot 

Use chkconfig to automatically create the necessary 
start/stop files for each run level.

See 'pinfo chkconfig'

        chkconfig  -  updates  and queries runlevel 
information for system

        chkconfig --list [name]
        chkconfig --add name
        chkconfig --del name
        chkconfig [--level levels] name 
        chkconfig [--level levels] name


chkconfig provides a simple command-line tool for 
maintaining the /etc/rc[0-6].d directory hierarchy by relieving 
system administra-tors of the task of directly manipulating  the 
numerous symbolic links in those directories.

You might even be able to create a stop script without the 
associated start script.

Each start/stop script in /etc/rc0.d - rc6.d is a symlink to 
the actual script in /etc/init.d/

The rc*.d start scripts have the format:


and the stop scripts


These scripts are run in ascending numeric order, so you 
will need to create a kill script (K00myscript) that is 
numbered befroe the script you want to affect.

Please see this old SuSE documentation for a good 
description of the Linux boot process:



Kind Regards,

Keith Roberts

In theory, theory and practice are the same;
in practice they are not.

This email was sent from my laptop with Centos 5.5