5

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.

2
  • Where do you see this hyphen? Is it in the output of a command? What command?
    – terdon
    Oct 28, 2014 at 13:28
  • Hello, thanks for replying.. I have updated my original question for more clarification.
    – PrgmError
    Oct 28, 2014 at 13:44

1 Answer 1

8

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.

3
  • Where is this documented? Could you give a source? I'm not saying it's wrong, just that your answer would be better if you could quote an official source for the information.
    – terdon
    Oct 28, 2014 at 14:10
  • @terdon I would have done had I been able to find one! Finally, found and added.. :o) Oct 28, 2014 at 14:31
  • Thanks. Dammit, this should be documented in a man page somewhere but I can't find it either.
    – terdon
    Oct 28, 2014 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .