There are many cryptic tutorials on starting Mysql or Apache on boot. While this may be a simple task for even not so hardcore admins, it can leave the rest of us scratching our heads. Luckily for Fedora/Redhad/CentOS user there is a utility called check config which, can help us with this elusive task. This is how:
As root, type the following to get a list of all services chkconfig handles:
This will print out a list of all the initscripts that are under the control of chkconfig (see Table 1):
Table 1 httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:off 3:off 4:off 5:off 6:offAn example of initscripts under the control of chkconfig
Here we see that the httpd initscript is started in runlevels 3, 4, and 5. The mysql initscript is started in runlevels 2, 3, 4, and 5, while the atd initscript is not started at all.
If you wanted to make Apache start in runlevel 2 as well, you would use the following:
chkconfig –level 2 httpd on
This tells chkconfig to create a symbolic link in /etc/rc.d/rc2.d that will start the httpd initscript. So when you boot into runlevel 2 now, Apache will start. Likewise, if there is a service that is currently running that you don’t want to have started, you can use chkconfig to turn it off. If, for example, you want to turn MySQL off for runlevels 2 and 5, you can use:
chkconfig –level 25 mysql off
If you want to turn MySQL off for all runlevels, you can use:
chkconfig –del mysql
If, at a later point, you want to turn MySQL back on, you can use:
chkconfig –add mysql
to re-enable it with its default settings.
Finally, if you want to simply list the settings for one service, you can do so by using:
chkconfig –list httpd
to see which runlevels httpd is configured to run in.