Thursday, September 5, 2013

chkconfig add service in linux


We all now we use chkconfig entry to survive the reboots. If you enable a service for a particular runlevel using chkconfig the service will automatically start when server reboots in that particular runlevel. In this post we will see how to add a service to chkconfig.

You can list the entries using the following command
[root@localhost init.d]# chkconfig --list Service
Service          0:off   1:off   2:on    3:on    4:on    5:off   6:off

Suppose you created a script for start/restart tomcat6 and want to add it to chkconfig, You can do it as follows.
[root@localhost init.d]# chkconfig --add tomcat6

No try listing it.
[root@localhost init.d]# chkconfig --list tomcat6
tomcat6         0:off   1:off   2:on    3:on    4:on    5:off   6:off

See the script will run if the server is booting in any of 2,3 or 4 runlevel.

If you want to start the script in runlevel 5 you can enable as follows
[root@localhost webapps]# chkconfig tomcat6 --level 2345 on

Now testing it.
[root@localhost ]# chkconfig --list tomcat6
tomcat6         0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@localhost ]#

No comments:

Post a Comment

Be nice. That's all.