PHP下利用shell后台运行PHP脚本,并获取该脚本的Process ID的代码
代码如下:
$command = '/usr/bin/php /pub/www/u111/job/Crondo/auto_collector.php &'; $process = proc_open($command, array(),$pipes); $var = proc_get_status($process); proc_close($process); //pid就是进程ID,至于为什么要加1,我现在也没有搞懂,经过多次的测试,发现$var['pid']得到的ID比实际的少1 $pid = intval($var['pid'])+1; //杀死进程 proc_close(proc_open('kill -9 '.$pid, array(), $pipes));
相关推荐
卖口粥湛蓝的天空 2020-09-15
xuebingnan 2020-11-05
Crazyshark 2020-09-15
zyyjay 2020-11-09
samtrue 2020-11-22
stefan0 2020-11-22
yifangs 2020-10-13
songshijiazuaa 2020-09-24
hebiwtc 2020-09-18
天步 2020-09-17
83911535 2020-11-13
whatsyourname 2020-11-13
zhouyuqi 2020-11-10
Noneyes 2020-11-10
mathchao 2020-10-28
王志龙 2020-10-28
wwwsurfphpseocom 2020-10-28