doufei4418 2015-06-23 16:17
浏览 94
已采纳

当echoed PID指定为PHP变量时,shell_exec()函数不起作用

I am having a hard time identifying the solution to my problem. Here is a simple explanation.

Using the following code, I am able to launch a script using the shell_exec() function :

shell_exec("nohup /usr/bin/php /home/script.php > /dev/null & echo $!");

This works perfectly.

But when I launch the PHP script using the shell_exec() function and assigning the returned PID using the following code, the script process is not launched and no action is completed (although the $pid is echoed correctly) :

$pid = shell_exec("nohup /usr/bin/php /home/script.php > /dev/null & echo $!");
echo 'Process ID : ' . $pid;

How can I retrieve the PID and execute the process for this "script.php" ?

  • 写回答

1条回答 默认 最新

  • dongyue110702 2015-07-21 16:13
    关注

    I finally found the problem with the process :

    Fact - PID was return before the script was executed

    Fact - "isPIDRunning()" Verification is made in "script.php" before it is executed.

    Result - Instead of avoiding the script to be launched twice, it is not even executed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器