Hi,
Now first we need to create a script to check for services and restart if any of them is down. Then we need to add the script as a cron job to autmatically execute it at any specified time interval. But what's the code to put inside the script ?
Here's it,
Quote:
/usr/bin/pgrep cpanel || /etc/init.d/cpanel restart
/usr/bin/pgrep httpd || /etc/init.d/httpd restart
/usr/bin/pgrep named || /etc/init.d/named restart
/usr/bin/pgrep ftp || /scripts/restartsrv_ftpserver
/usr/bin/pgrep exim || /etc/init.d/exim restart
/usr/bin/pgrep mysql || /etc/init.d/mysql restart
/usr/bin/pgrep courier || /scripts/restartsrv_courier
/usr/bin/pgrep sshd || /etc/init.d/sshd restart
|
Thats it. Save it to any filename say /root/check_services.
Give execute permission to the script,
Quote:
|
chmod 700 /root/check_services
|
Then add it as a cron job. You can use the following command to add a line for the new cron job.
OR
Just edit the file /var/spool/cron/root and add the line to it,
for eg: here is a sample line for executing the script every 15 minutes,
Quote:
|
*/15 * * * * /bin/bash /root/check_services
|
save the file and restart cron service.
Quote:
|
/etc/init.d/crond restart
|
Thats it, done.
Now to check whether a vps is down and restart it a script has to be setup on the main hardware node. For that you will need to contact us. Just leave a word at our help desk.
Cheers !