What does the hyphen mean in chkconfig run level in an /etc/init.d script

chkconfiginit-scriptinit.d

I just have a simple question but scouring the search engines I have not found any explanation of what the - (hyphen) in the chkconfig runlevel actually stands for within the init script file.

For example in /etc/init.d/mysqld the first few lines are like this:

#!/bin/bash
#
# mysqld        This shell script takes care of starting and stopping
#               the MySQL subsystem (mysqld).
#
# chkconfig: - 64 36

If anyone could provide me a link explaining this that would be awesome.

Best Answer

The hyphen (-) found in an init script:

#!/bin/sh
#
# chkconfig: - 24 73

means that the service should not be started in any run levels by default, only stopped.

It replaces a list of run levels (e.g. 345) as shown below:

#!/bin/sh
#
# chkconfig: 345 24 73

Therefore if you use:

chkconfig --add <script>

then no start links will be created in any of the init directories.

$ ll rc*.d/*script*
lrwxrwxrwx. 1 root root 17 Apr 24  2014 rc0.d/K73script -> ../init.d/script
lrwxrwxrwx. 1 root root 17 Apr 24  2014 rc1.d/K73script -> ../init.d/script
lrwxrwxrwx. 1 root root 17 Apr 24  2014 rc2.d/K73script -> ../init.d/script
lrwxrwxrwx. 1 root root 17 Apr 24  2014 rc3.d/K73script -> ../init.d/script
lrwxrwxrwx. 1 root root 17 Apr 24  2014 rc4.d/K73script -> ../init.d/script
lrwxrwxrwx. 1 root root 17 Apr 24  2014 rc5.d/K73script -> ../init.d/script
lrwxrwxrwx. 1 root root 17 Apr 24  2014 rc6.d/K73script -> ../init.d/script

Notice only the Kill scripts links exist (K73script).

References:

A reference to this can be found on softpanorama.org:

The first line tells chkconfig what runlevels the service should be started in by default, as well as the start and stop priority levels. If the service should not, by default, be started in any runlevels, a - should be used in place of the runlevels list.

Related Question