一次执行多个shell_exec?

时间:2011-07-06 00:12:38

标签: php shell shellexecute shell-exec

如何一次执行多个shell_exec?

另外,如何切换每个进程以查看test.php文件的输出?我需要知道每个进程(php文件)正在做什么。

看一看,例如:

的index.php

<?php
shell_exec("php test.php");
shell_exec("php test.php");
shell_exec("php test.php");
?>

这不是我想要的方式,首先必须首先完成shell_exec(test.php),然后它将转到下一个shell_exec。

test.php的

<?php
$section = rand(123,123);
$x = 1;
while($x <= 50) {
 print $section . ": " . $x . "\n";
 $x++;
 sleep(1);
}
?>

执行shell_exec时不会输出,但是当我在shell中手动键入php test.php时,它会输出。

或者有没有办法打开多个炮弹?

这是一个快速示例,但是我将执行多个PHP文件来运行CURL

1 个答案:

答案 0 :(得分:1)

shell_exec(“php test.php&amp; php test.php”);

最好的办法是让这些脚本将输出记录到文件中,并在运行shell_exec()后主动解析它。