保存一下代码为502.sh
1 | #!/bin/bash |
2 | website=http: //api .bbshenqi.com /User/ |
3 | if |
4 | curl -I $website| grep "HTTP/1.1 502" |
5 | then |
6 | /alidata/server/nginx/sbin/nginx -s reload |
7 | /alidata/server/php/sbin/php-fpm reload |
8 | fi |
这样会在出现502错误的时候,重启nginx和php-fpm
获取权限
1 | chmod +x 502.sh |
添加到crontab定时任务(每八分钟执行一次)
1 | crontab -e |
2 | * /5 * * * * /shell/502 .sh |