从后台进程启动后台进程

时间:2023-01-07 19:16:26

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?

它不是从后台进程启动后台进程的受支持方式,还是有更好的解决方法?

2 个解决方案

#1


1  

Try php test.php < /dev/null & - some Unix distributions seem to expect some input and send the process idle to background. Tested on Fedora Linux (bash) you can start php test.php & but it isn't executed. Check with jobs running background process - catch from background and execute with fg.

试试php test.php

#2


0  

It's possible by using proc_open. I've written a micro-framework as POC, which is using this technique.

通过使用proc_open可以实现。我写了一个微框架作为POC,正在使用这种技术。

#1


1  

Try php test.php < /dev/null & - some Unix distributions seem to expect some input and send the process idle to background. Tested on Fedora Linux (bash) you can start php test.php & but it isn't executed. Check with jobs running background process - catch from background and execute with fg.

试试php test.php

#2


0  

It's possible by using proc_open. I've written a micro-framework as POC, which is using this technique.

通过使用proc_open可以实现。我写了一个微框架作为POC,正在使用这种技术。