Using chkconfig to control init scripts in Centos

chkconfig is a very useful utility that allows you to quickly deploy the symlinks in the various rc directories that control what gets launched at boot time and shutdown when powerinf down.

To add or remove an init script to a run level is very easy with the chkconfig command. Here are some useful examples:

1. To list the current configuration of all init scripts:


chkconfig --list

produces output such as…

[root@CentosOpenBD3 ~]# chkconfig --list
NetworkManager 0:off 1:off 2:off 3:off 4:off 5:off 6:off
acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off
apmd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

... etc

2. To find out if a service is set currently configured to be launched at boot time in the current runlevel:

chkconfig mysqld

3. To add a script to run levels 3,5 4 & 5

chkconfig --level 345 mysqld on

(just use ‘off’ instead of ‘on’ if the script shouldn’t be run at that run level)

4. To remove a script

chkconfig --del mysqld