January 4

restart_apache_if_load.sh

#!/bin/bash
load=`/usr/bin/uptime | awk -F 'load average: ' '{print$2}'|awk -F ',' '{print$1}'`
check=`echo "$load>8"|bc`
if [ "$check" -eq "1" ]; then
killall -9 php -v;killall -9 php-cgi -v;killall -9 -u nobody -v; /scripts/restartsrv_httpd; service nginx restart
time=`/bin/date +'%H:%M:%S %Y-%m-%d'`
echo "Apache has been restarted due to load $load at $time" >> /root/restart_apache.log
fi


Copyright 2021. All rights reserved.

Posted 4 January 2017 by admin in category "simple memo

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.