Nginx若出现502 Bad Gateway 的临时解决方案

保存一下代码为502.sh

1#!/bin/bash
2website=http://api.bbshenqi.com/User/
3if
4curl  -I $website|grep "HTTP/1.1 502"
5then
6/alidata/server/nginx/sbin/nginx -s reload
7/alidata/server/php/sbin/php-fpm reload
8fi

这样会在出现502错误的时候,重启nginx和php-fpm

获取权限

1chmod +x 502.sh

 

添加到crontab定时任务(每八分钟执行一次)

1crontab -e
2*/5 * * * * /shell/502.sh

评论关闭