Nginx 502自动重启脚本
在/root/scripts/下添加以下脚本文件monitor-php-fpm.sh
logFile=/root/scripts/log/php-fpm.log URL=http://witmax.cn result=`curl -I ${URL} | grep "HTTP/1.1 502"` if [ -n "$result" ]; then echo "##" "502" $(date +"%Y-%m-%d %H:%M:%S") "php-fpm restarted" | mail -s "nginx 502 # php-fpm restarted" i@witmax.cn echo `date "+%Y-%m-%d %H:%M:%S"` nginx 502 bad gateway >> ${logFile} kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` fi
添加定时任务crontab -e
*/1 * * * * /root/scripts/monitor-php-fpm.sh
好了,以后每分钟就会自动检测502,如果是的话就重启nginx
至于502的原因和解决方案见这篇
标签: Nginx
还没有人抢沙发呢~