502状态码重启php-fpm

#!/bin/bash
log=/var/log/nginx/access_log
#502_n=`tail -n 300 $log |grep -c ‘502’`
while :
do
n=`tail -n 300 $log |grep -c “502”`
if [ -z $n ]
then
exit
fi

if [ $n -gt 100 ]
then
/etc/init.d/php-fpm restart >/dev/null 2>/tmp/php-fpm.err
fpm_p_n=`pgrep -l php-fpm|wc -l`
if [ $fpm_p_n -eq 0 ]
then
python /usr/local/sbin/mail1.py wqsfree@163.com “php-fpm重启失败” “`head -1 /tmp/php-fpm.err`”
exit
fi
fi
sleep 10
done

发表评论