求个LNMPA自动重启脚本
不知道为什么,负载经常莫名其妙的到20多,然后就挂在那了。。军哥,求个LNMPA的脚本内存剩余50M时自动重启lnmpa , 负载到20时,也自动重启
论坛里看到一个502错误自动重启的,不过好像是LNMP的,不知道能不能用
回复 1# 的帖子
稍微一修改502脚本就行了设个最大负载 max_load=20
当前负载cur_load=`uptime | awk '{print $(NF-2)}' | sed 's/,//'`
然后$cur_load > $max_load 时重启 #!/usr/bin/php
<!--?
$url = 'http://www.xiuzhan.net';
$cmd = '/root/lnmpa 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();
}
}
$max_load=20;
$cur_load=`uptime | awk '{print $(NF-2)}' | sed 's/,//'`;
if($cur_load > $max_load){
shell_exec($cmd);
exit();
}
?>
不知道这样改对不对
页:
[1]