放到crontab里一分钟执行一次。URL和CMD根据自己的改。
#!/usr/bin/php
$url = 'http://www.diahosting.com';
$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();
}
}
?>
至于crontab,请自行Google搜索
来源:http://www.hostloc.com/viewthread.php?tid=19208&page=1#pid235729
© 2010, 酷胖优惠码. 版权所有.

不错,有用
擦,我看也是
刚才看了看原帖。原来COPY过来的不完整。呵呵。少了关键句和原理说明。
转得太快的缘故,后面原帖改动了,呵呵