How to monitor and auto restart cron service using cPanel chkservd?

Sometimes it is necessary to monitor a crond service itself on a cPanel server. cPanel offers ‘chkservd’ (a monitoring daemon) that monitors the services that are included in it and restarts them if they are found offline.

However, cPanel do not provide an option to include the ‘crond’ service under chkservd. The following method can be used to add crond service under chkservd.

Create a crond file under the chkservd.d directory where the files of all the services are placed:

# pico /etc/chkserv.d/crond

Add the following and save the file:

service[crond]=x,x,x,/etc/init.d/crond restart,crond,root

Now you need to edit the chkservd configuration file and enable the crond service for monitoring

# pico /etc/chkserv.d/chkservd.conf

add the following line at the end of the file

crond:1

Now, save the file and restart the chkservd service for the new changes to take affect:

# /scripts/restartsrv chkservd

In order to verify if chkservd auto-restarts the crond service if it is offline, stop the service manually

# service crond stop

and watch the chkservd logs

# tail -f /var/log/chkservd.log

You will notice that the crond service is restarted automatically within 5 minutes.

This entry was posted on Tuesday, June 29th, 2010 and is filed under cPanel Management. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.