How to start a service at boot time which chkconfig

Short and sweet and to the point: how to make sure a given service starts when the machine boots?

Red Hat and Centos provide the chkconfig command to do this. you should always use this command as the user root. I am just going to give a few examples below, for lack of time:

1. Is httpd (AKA Apache) started at boot time?

Use the --list option for this:

[root@galactus ~]# chkconfig --list httpd
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off

2. Activate httpd (AKA Apache) at boot time:

[root@galactus ~]# chkconfig httpd on


[root@galactus ~]# chkconfig --list httpd
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

And ... it's on! Great!

3. Same thing with mysqld

One more time, with feelings:

[root@galactus ~]# chkconfig mysqld on
[root@galactus ~]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

As a reminder, you can check the current run-level of your machine with the command who -r.

Also, if you are under Suse Linux, you can use the command insserv service_name to do the same, even though Suse also has chkconfig.

See Also: