I've have this script who run another one in the background, without waiting to it to finish.
My script.php:
$cmd = "nohup php script2.php > /dev/null 2>&1 &";
exec($cmd);
My script2.php:
sleep(10);
mail("me@mail.com","test","ok");
If I run it in commandline, it works fine: the call finish inmediately and I get a new mail in my inbox after 10 seconds.
But if I call to my script with http://myserver/script.php, I don't receive anything.
Notice that using:
$cmd = "php script2.php > /dev/null 2>&1";
works in both calling methods. So there's something wrong with the http call and the use of nohup.
I also tried passthru and shell_exec instead of exec with the same results.
Also tried this just in case, but it didn't work in any case.