我在运行连续后台进程时遇到问题,其中父进程启动2或3子进程然后自行结束,子进程有大量计算,因此他们将花费大量时间。无法使用exec命令运行PHP
我使用exec命令来启动进程,但不知道它不启动它既不产生任何错误(错误报告后,E_ALL和的display_errors)
这里是我正在努力要做到这一点
error_reporting(E_ALL);
ini_set('display_errors',1);
$output = '';
$dir = dirname(__FILE__).'/';
//$cmd = "nohup php {$dir}/background-service.php > /dev/null & echo $!";
$cmd = "nohup php background-service.php >/dev/null 2>&1 &";
exec($cmd);
背景service.php
<?php
ini_set('max_execution_time', 0);
ini_set('display_errors',1);
file_put_contents('a'.time().'.txt',"this is the test code");
?>
时,我打它直接生成一个文件的文件,但不以exec,我测试过EXEC启用(Ubuntu的服务R)
if ($safe_mode = ini_get('safe_mode') && strtolower($safe_mode) != 'off')
{
echo 'Safe Mode is Disabled';
}
else
echo 'Safe Mode is Enabled<br/>';
if (in_array('exec', array_map('trim', explode(',', ini_get('disable_functions')))))
{
echo 'exec is Disabled';
}
else
echo 'exec is Enabled<br/>';
有人请告诉我,我错了它,我怎么能检测如果禁用由服务器
感谢
感谢运行完整路径,工作,但问题是我想run.php启动PHP文件并结束自己正常,现在它等待exec文件完全执行,它应该只是调用它并终止本身 – MZH 2013-02-28 07:11:12