//下面两种情况,如果命令执行过长的话,都会堵塞,造成页面超时
$command = ‘php exe.php‘
popen($command,‘r‘)
pclose(popen($command,‘r‘))
//不堵塞执行,不会造成页面超时
$command = ‘nohup php exe.php &‘
pclose(popen($command,‘r‘))
查看该进程
执行完之后,该进程消失
强行结束:kill -9 13613
另外注意,if(flock($fp,LOCK_EX))
会阻塞到获取排它锁.
解决方案2:
pclose(popen(‘nohup ‘ . $cmd . ‘ & 2>&1‘, ‘r‘));