Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

up vote 7 down vote accepted

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).

share|improve this answer
    
I ran this chkconfig ntpd on without ever running --add and that seemed to work fine. –  DD. Apr 30 '12 at 14:42
1  
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

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.

share|improve this answer

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.