网页请求502的定时重启

实现逻辑:定时监测请求网页返回的状态,若出现502的情况,重启php5-fpm

1、写个shell脚本 gateway.sh  当出现502问题重启进程,并记录重启日志

#!/bin/bash

MY_URL="http://www.****.com/"

RESULT=`curl -I $MY_URL|grep "HTTP/1.1 502"`

if [ -n "$RESULT" ]; then

/etc/init.d/php5-fpm restart

echo "502重启时间:`date '+%Y%m%d %H%M%S'`" >> 502.txt
fi

2、用crontab定时每一分钟访问一次shell脚本

*/1 * * * * sh /root/gateway.sh

 

posted @ 2017-01-10 14:27  休于连城  阅读(269)  评论(0)    收藏  举报