I've a problem in running a continous background process in which the parent initiate 2 or 3 child process then end itself, child processes have heavy computation so they will take alot of time.
I'm using exec command to start the process but don't know it doesn't start neither it generates any error(error reporting is on,E_ALL and display_errors)
Here is how I'm trying to do this
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 );
background-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");
?>
when I hit the file directly it generates a file, but not with exec, I've tested exec is enabled(ubuntu server)
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/>';
Someone please tell me where I'm wrong in it, how can I detect if its disabled by server
Thanks