502 Bad Gateway 自动重启脚本@LNMP

一个简单的脚本,用来监控502的,如果遇到502,自动重启PHP进程。适用于LNMP环境。

以下文件,存放于 /root 或其它目录:

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

给予可执行权限:

  1. chmod +x /root/php.sh

 

通过 crontab 设置自动运行:

 

  1. crontab -e
  2. * * * * * /root/php.sh

 

阅读剩余
THE END