How to set services to start & stop automatically.

How to set services to start & stop automatically.



Red Hat and Red Hat based Linux distributions make use of the script called chkconfig to enable and disable the system services running in Linux.

For example, to enable the apache webserver to start in certain run levels, you use the chkconfig script to enable it in the desired run levels as follows:

# chkconfig httpd --add
# chkconfig httpd on --level 2,3,5

This will enable the apache webserver to automatically start in the run levels 2, 3 and 5. You can check this by running the command:

# chkconfig --list httpd

One can also disable the service by using the off flag as shown below:

# chkconfig httpd off
# chkconfig httpd --del

Red Hat also has a useful script called service which can be used to start or stop any service. Taking the previous example, to start apache webserver, you execute the command:

# service httpd start

and to stop the service…

# service httpd stop

The options being start, stop and restart which are self explanatory.

No comments:

Post a Comment