502 Bad Gateway 自动重启脚本
2019-06-25 10:04:55

502这里只是临时解决办法。

首先创建一个sh脚本:

cd vi php.sh

其次就是脚本的内容了。如下:

#!/bin/bash
MY_URL="https://qq.com"
RESULT=`curl -I $MY_URL|grep "HTTP/1.1 502"`
if [ -n "$RESULT" ]; then
        /etc/init.d/php-fpm restart
fi

然后给他权限:

chmod +x /root/php.sh

通过 crontab 设置自动运行:

crontab -e

然后键入:

* * * * * /root/php.sh

最后保存文件即可和vi命令的使用是一样的~

 

如果提醒没有什么软件,例如没有 vi即:

yum install vim -y