How To Restart Apache Using cron If the Load Gets Too High

Published Date Author: , Posted February 3rd, 2016 at 6:35:43am

There are times when the hackers slam my servers and the load gets too high. I use a very simple bash script as a cron job to monitor the load and take action when it gets too high.

The script will stop httpd, sleep for a configurable period of time (currently 3 minutes), then start httpd.

As always, YMMV!

Add this to the root cron, making sure the paths match your environment:
* * * * * /root/restart_apache_if_load_hits_threshold.sh >> /var/log/restart_apache_if_load_hits_threshold.log 2>&1

restart_apache_if_load_hits_threshold.sh
(Be sure to modify the email address in two places…)

No comments as yet.

Leave Your Comment  Leave a comment

All fields marked with "*" are required.