What's the difference between chkconfig on vs chkconfig --add?
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).
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.