时间:2021-07-01 10:21:17 帮助过:25人阅读
代码如下:
<?php
$url = 'http://blog.rebill.info';
$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();
}
}
代码如下:
*/1 * * * * /usr/bin/php /root/crontab/nginx502.php