0

我有 2 个 php 文件。一个run_server.php如下:

<?php
echo "Initializing";
shell_exec("php -q server.php &");
echo "finishing !";
?>

在 server.php 中,我正在运行一个服务器和 2 个客户端,如下所示:

<?php
//ini_set('max_execution_time', 5);
ini_set('set_time_limit', 10);
$Command = 'commands.txt';  
exec(" parallel -j 8 < $Command");  
?>

Commands.txt 如下:

code/./server &
clients/./O 180.215.167.197 &
clients/./X 180.215.167.197 &

这是一个机器人程序,我从 run_server.php 调用的 server.php 文件运行一个服务器和 2 个客户端。我的问题是这条线

shell_exec("php -q server.php &");

即使在服务器和客户端执行完成后也不会返回。我试着放一个

max_execution_time / set_time_limit

但没有帮助。有没有什么方法可以让我在一段时间后从 server.php 强制返回 run_server.php ?

提前致谢。

4

1 回答 1

0

header();例如,使用。

<?php
echo "Initializing";
shell_exec("php -q server.php &");
header('location:http://mydomain.com/server.php');
echo "finishing !";
?>
于 2014-02-03T04:33:20.610 回答