我已经为这个问题挣扎了2个星期,我使用phpseclib从网络发送命令到路由器执行不同的行为,其中之一是重启路由器的网络接口,我很好地重启网络接口,但在运行命令后,整个apache冻结,并且没有响应任何其他http请求,我使用的是phpseclib 0.3.5。首先非常感谢你的帮助
Javascript
$.ajax({
ajax work here to call the runCMDAdvance function and with timeout specified
});PHP
//function to run the command
function runCMDAdvance($sshIP, $cmd, $tVal,$tarIP){
$ssh = new Net_SSH2($sshIP,$this->port);
if (!$ssh->login($this->username, $this->password)){
echo "Bad Login";
return false;
}
//set timeout for running ssh command, should be done after the ssh object has been initialized
$tVal>0 ? $ssh->setTimeout($tVal):"";
$res = $ssh->exec($cmd);
$ssh->disconnect();
return $res;
}
$cmd = INCL_PATH . ' && ' . '/sbin/uci commit network && '.'/sbin/uci commit dhcp && '.'/etc/init.d/network restart 2>&1 && exit'."\n";
$res = $ssh2_conn->runCMDAdvance($ip, $cmd, 20, "");我的猜测是,当执行重新启动网络接口时,AP会断开连接,并以某种方式使phpseclib崩溃,但我不知道如何解决这个问题。任何帮助都将不胜感激。
更新:我刚刚做了一个实验,每当我运行上面的ssh命令时,web服务器需要15.3分钟来处理另一个请求……http://i102.photobucket.com/albums/m112/ihmcjacky/Mobile%20Uploads/000_zpscc73f7f0.jpg
发布于 2013-11-23 21:13:38
致neubert:感谢您的反馈,实际上大多数命令使用phpseclib都运行得很好。
关于服务器无响应,如果无法避免,是否可以缩短服务器挂起的“死机时间”?或者其他可行的解决方案?
https://stackoverflow.com/questions/20144367
复制相似问题