chkconfig is used to ensure services restart when a server is rebooted

  • chkconfig –list lists the status of the services (on or off)
  • chkconfig –level 3 SERVICE on will ensure service SERVICE starts when the server enters run level 3

Creating a new service (start script)

First create your script in /etc/init.d . It should have the format:

 # chkconfig: 2345 20 80
 # description: Description comes here....
 # Source function library.
 . /etc/init.d/functions
 start() {
     # code to start app comes here 
     # example: daemon program_name &
 stop() {
     # code to stop app comes here 
     # example: killproc program_name
 case "$1" in 
        # code to check status of app comes here 
        # example: status program_name
        echo "Usage: $0 {start|stop|status|restart}"
 exit $?

The numbers on the chkconfig line refer to the run levels it will start at, the start order and the stop order. Next, use chkconfig to add the script as a service

 chkconfig --add newscript

Define at which levels you need the script to run

 chkconfig --level 2345 newscript on

Then check everything is OK using the chkconfig –list command

Recent Changes

Contribute to this wiki

Why not help others by sharing your knowledge? Contribute something to this wiki and join out hall of fame!
Contact us for a user name and password