I have to execute a php script (test.php) in the background. I tried this but it's not working:
<?
$cmd = "php /home/megad404/www/prove/test.php &> /dev/null &";
exec('/bin/bash -c "'.$cmd.'"',$output,$return);
if($return===0)
{
echo 'Successful';
}
else
{
echo 'Unsuccessful';
}
?>
It returns "Successful" but it doesn't execute test.php
test.php:
<?
file_put_contents(date("s"),"");
sleep(5);
file_put_contents(date("s"),"");
sleep(5);
file_put_contents(date("s"),"");
?>
test.php writes a file every 5 second and it works fine, except if I try to execute it in the background with the first script.
Could it be a server issue? Is there another way to run a script in the background?