【发布时间】:2011-07-06 10:08:47
【问题描述】:
我正在后台运行多个shell_exec、process.php
在shell/ssh上,我执行如下代码:username [~/public_html/curl]# php index.php
示例....
index.php
<?php
shell_exec("php process.php > /dev/null 2>&1 &");
shell_exec("php process.php > /dev/null 2>&1 &");
shell_exec("php process.php > /dev/null 2>&1 &");
shell_exec("php process.php > /dev/null 2>&1 &");
?>
process.php
<?php
$section = rand(999,999999);
$z = 1;
print "STARTED .... \n";
while($z <= 10) {
print "---------------------------------\n";
print $section . ": " . $z . "\n";
$z++;
sleep(2);
}
print "LOOP FINISH at " . time();
?>
当process.php's 运行时,我遇到了两个问题:
- 我看不到
process.php的输出(我需要知道他们在做什么) - 我需要知道哪个过程已经完成,哪个过程已经开始。
实时记录输出的最佳方式是什么?保存到文本文件中?或者对mysql数据库(logs表)怎么做?
【问题讨论】:
-
试试看这里stackoverflow.com/questions/6252966/…zneak 建议我使用
proc_open