Simple Cron Job to Restart HTTPd and DB on cPanel

Issue: Require solution on cPanel / WHM server to restart web server and database each hour, without manual input.

Solution: Use a cronjob.

SSH into server as root and:

crontab - e

Then add the following two lines, which will restart Apache and MariaDB / MySQL every hour:

5 * * * * /usr/local/cpanel/scripts/restartsrv_apache > /dev/null 2>&1
6 * * * * /usr/local/cpanel/scripts/restartsrv_mysql > /dev/null 2>&1

Using the above, will restart Apache at 5 minutes past every hour, and MariaDB / MySQL at 6 minutes past every hour.

1 thought on “Simple Cron Job to Restart HTTPd and DB on cPanel”

Leave a comment

BlogLogistics