VPS侦探论坛

 找回密码
 注册
查看: 5342|回复: 1

军哥,关于自动重启502的脚本

[复制链接]
发表于 2011-12-16 18:41:56 | 显示全部楼层 |阅读模式

有的时候不出现502错误,出现网站打不开,重启一下就好了,如果改装一下,用网站的title判断,假如要求:不等于502的时候重启,这里面应该怎么改:

#!/usr/bin/php
<?
$url = 'https://www.vpser.net';
$cmd = '/usr/local/php/sbin/php-fpm restart';

for($i = 0; $i < 5; $i ++){
$exec = "curl --connect-timeout 3 -I $url 2>/dev/null";
$res = shell_exec($exec);

if(stripos($res,'502 Bad Gateway') !== false){
shell_exec($cmd);
exit();
}
}
?>

谢军哥!!!!
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-12-16 21:00:52 | 显示全部楼层


  1. #!/bin/bash
  2. URL="https://www.vpser.net"
  3. RESULT=`curl $URL|grep "VPS侦探"`

  4. if [ -n "$RESULT" ]; then
  5. echo "ok"
  6. else
  7. echo "502了,我去重启"
  8. /usr/local/php/sbin/php-fpm start
  9. fi
复制代码
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-21 20:49 , Processed in 0.024975 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表