#!/bin/sh
TOP_SYS_LOAD_NUM=20
SYS_LOAD_NUM=`uptime | awk '{print $(NF-2)}' | sed 's/,//'`
echo $(date +"%y-%m-%d") `uptime`
if [ `echo "$TOP_SYS_LOAD_NUM < $SYS_LOAD_NUM"|bc` -eq 1 ]
then
echo "##" $(date +"%y-%m-%d %H:%M:%S") "stop php mysql free -m"
/usr/local/php/sbin/php-fpm stop
service mysql stop
free -m
sleep 5
for i in 1 2 3
do
if [ `pgrep php | wc -l` -le 0 ]
then
/usr/local/php/sbin/php-fpm start
service mysqld start
sleep 10
echo "##" $(date +"%y-%m-%d %H:%M:%S") "start php mysql"
fi
done
else
if [ `pgrep php | wc -l` -le 0 ]
then
/usr/local/php/sbin/php-fpm restart
service mysql restart
sleep 10
echo "##" $(date +"%y-%m-%d %H:%M:%S") "restart php mysql "
fi
fi