5

Whats the difference between using chkconfig on and using chkconfig --add?

DD.
  • 3,024
  • 10
  • 34
  • 50

3 Answers3

7

chkconfig --add adds a new service to the list of services managed by chkconfig. I believe --add is an implicit on.

chkconfig on sets the runlevel for the service.

That said, I tend to use chkconfig -add for adding new services to a system, but ntsysv to manage them (on RHEL-like systems).

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • 1
    I ran this chkconfig ntpd on without ever running --add and that seemed to work fine. – DD. Apr 30 '12 at 14:42
  • 2
    `chkconfig --add` is for adding *new* services; e.g. services or daemons that are not already registered on the server. For instance, if I download software that doesn't have an init script and I write one... I would have to place that script in `/etc/init.d/` and run `chkconfig --add` to allow it to be managed in the same manner. – ewwhite Apr 30 '12 at 14:44
1

In Redhat/CentOS, there is one line in the init script which looks like

# chkconfig: - 65 10

If you use --add when the first arg of above line is "-", this adds no start links, only the kill links. So for --add to work, you have to edit the init script and change to e.g.

# chkconfig: 345 65 10

But if chkconfig --add ... was executed with the "-" as first arg (which is mostly the case from rpm post script): Changing afterwards the first arg and reexecute chkconfig --add has no effect as long as the kill links are present. In this case --list shows off for all runlevel:

chkconfig --list saslauthd
saslauthd       0:off   1:off   2:off   3:off    4:off    5:off    6:off

To make --add work in this case, you first have to use --del, then the output of --list is:

chkconfig --list saslauthd
service saslauthd supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add saslauthd')

Now you can use --add and it has the desired effect.

Alternatively you can use "on" with the --level argument to avoid the need of editing the init script and to avoid first --del followed by --add.

0

Which OS are you running? If you run chkconfig with only a service name as an argument, I believe RHEL's chkconfig simply checks if that service is set to run at which ever run level you are currently running (said Dr. Suess).

Univ426
  • 2,139
  • 14
  • 26