查看php-fpm是否运行的脚本,自动发送邮件通知
###########################
#!/bin/bash
###查看fpm服务是否运行
time="$(date +"%Y%m%d-%H:%M")"
i=`netstat -anpt | grep php-fpm | awk '{print $4}' | awk -F: '{print $2}' | wc -l`
service="/sbin/service"
if [ $i = 0 ]
then
$service php-fpm restart
echo "$time php-fpm service is down .... restart..." >> /var/log/www/php-fpm.log
echo "$time php-fpm service restart ...." > /root/mail-php.txt
mail -s "$time php-fpm restart" xxx@xxx.com < /root/mail-php.txt
fi
###########end###############