【问题标题】:Execute multiple shell_exec at once?一次执行多个shell_exec?
【发布时间】:2011-07-06 00:12:38
【问题描述】:

如何一次执行多个 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 时,它会输出。

或者有没有办法打开多个shell?

这是一个简单的示例,但是我将执行多个 PHP 文件来运行 CURL

【问题讨论】:

    标签: php shell shellexecute shell-exec


    【解决方案1】:

    shell_exec("php test.php&php test.php");

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

    【讨论】:

    • 输出到文件是个好主意,但文件锁定或类似文件已打开没有问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-09
    • 2018-06-19
    • 2017-05-01
    • 2018-07-22
    • 1970-01-01
    相关资源
    最近更新 更多