Simplified, fixed for Ubuntu, including switch to bash for decimal …

Thursday, 28th March 2024

Comment on Auto restart Apache on High server load (bash shell script) – Fixing Apache server temporal overload issues by Whit.

Simplified, fixed for Ubuntu, including switch to bash for decimal values:

#!/bin/bash
check=`cat /proc/loadavg | sed ‘s/./ /’ | awk ‘{print $2}’`
max_load=’15’
high_load_log=’/var/log/apache_high_load_restart.log’;
apache_init=’/etc/init.d/apache2′;
if [[ $check > $max_load ]]; then
$apache_init stop
sleep 5;
$apache_init restart
echo “$(date) : Apache Restart due to excessive load | $check |” >> $high_load_log;
fi

Share this on:

Comments are closed.