Questions? Feedback? powered by Olark live chat software
Author Avatar

Loadcheck script for http overload

Written by: on 07 May 2021 09:15 AM 07 May 2021 09:15 AM
Sometimes Apache on cPanel servers can become overloaded, this can be caused by scrapers, HTTP DDOS attacks or just a general spike in traffic.

This script simply checks the load and if it's over 20 it restarts the http (Apache) service. This can help prevent extended downtime or server crashing. The following is done in SSH / Terminal.

pico /root/

Enter the contents:

check=$(cat /proc/loadavg | awk '{print $1}')

check=$( printf "%.0f" $check )

if [ "$check" -gt 50 ]; then

/usr/bin/systemctl restart httpd.service


echo $check

Save and exit

chmod 755 /root/

crontab -e

Enter this as the last line:

* * * * * /root/ > /dev/null 2>&1

Save and exit

(0 vote(s))
Not helpful