[英]Start background processes from a background process
I have a PHP script say test.php
in linux Ubuntu, in this PHP script I use shell_exec()
to start several background processes. 我在Linux Ubuntu中有一个PHP脚本说test.php
,在此PHP脚本中,我使用shell_exec()
启动了几个后台进程。
When I execute php test.php
, the background processes are started as expected, but when I run php test.php &
, those several background processes are not started. 当我执行php test.php
,后台进程将按预期方式启动,但是当我运行php test.php &
,则不会启动这几个后台进程。
Is it not a supported way to start background processes from a background process, or is there a better to go about this? 从后台进程启动后台进程不是受支持的方法,还是有更好的方法呢?
Try php test.php < /dev/null &
- some Unix distributions seem to expect some input and send the process idle to background. 尝试php test.php < /dev/null &
-一些Unix发行版似乎期望一些输入并将进程空闲发送到后台。 Tested on Fedora Linux (bash) you can start php test.php &
but it isn't executed. 在Fedora Linux(bash)上经过测试,您可以启动php test.php &
,但未执行。 Check with jobs
running background process - catch from background and execute with fg
. 检查运行后台进程的jobs
-从后台捕获并使用fg
执行。
It's possible by using proc_open . 使用proc_open是可能的。 I've written a micro-framework as POC, which is using this technique. 我已经使用该技术编写了一个微框架,称为POC。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.