php exec()后台进程问题 [英] php exec() background process issues
本文介绍了php exec()后台进程问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下命令在后台处理文件,但是它什么也没做.
I'm trying to process a file in the background with the following command, but it does nothing.
exec("php csv.php $file $user > /dev/null &", $output);
如果我删除> /dev/null &
,则文件会处理,但不会在后台处理.
If I remove > /dev/null &
then the file processes, but not in the background.
exec("php csv.php $file $user", $output);
有什么想法吗?
推荐答案
注意:
如果使用此功能启动程序,则要使其在后台继续运行,必须将程序的输出重定向到文件或其他输出流.否则,将导致PHP挂起,直到程序执行结束.
If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.
http://php.net/manual/zh/function.exec.php
如此:
exec("php csv.php $file $user > /dev/null &"); // no $output
这篇关于php exec()后台进程问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文