PHP脚本不会在后台运行 [英] PHP script won't run in the background
本文介绍了PHP脚本不会在后台运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在后台运行php CLI脚本,但它不会运行-它的状态为Stopped SIGTOU(试图写输出)-以下是详细信息
I am trying to run a php CLI script in the background and it just won't run - it has a status of Stopped SIGTOU (Trying to write output) - Here are the details
- Mac OS X Lion 10.7.2
- 带有Suhosin-Patch(cli)的PHP 5.3.6(内置:2011年9月8日19:34:00)
我创建了一个基本脚本test.php
I created a basic script test.php
<?php echo 'Hello world'.PHP_EOL; ?>
以下是各种测试的结果:-
Here are the results of various tests:-
-
php -f test.php
(将显示Hello World) -
php -f test.php >test.log 2>&1
(您好,世界进入了test.log) -
php -f test.php >test.log 2>&1 &
---我得到了[1]+ Stopped(SIGTTOU) php -f test.php > test.log 2>&1
-只是坐在那里,什么也没记录,但是lsof显示日志文件已打开
php -f test.php
(Hello world gets displayed)php -f test.php >test.log 2>&1
(Hello world gets put into test.log)php -f test.php >test.log 2>&1 &
--- I get[1]+ Stopped(SIGTTOU) php -f test.php > test.log 2>&1
-- and the job just sits there doing nothing nothing gets logged however lsof shows the log file is open
这与PHP有关吗?类似的shell脚本在后台执行也没有问题.
It is something to do with PHP? A similar shell script gets executed no problems in the background.
推荐答案
如果在您的php构建中启用了readline,则只需传递/dev/null作为输入即可.
If readline is enabled in your build of php, simply pass /dev/null as the input.
在上面的示例中,应该是:
In your example above, it would be:
php -f test.php </dev/null >test.log 2>&1
这篇关于PHP脚本不会在后台运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文