PHP exec() not executing php file
Posted on 2008-10-30
I am trying to call a PHP file to run as a background process from another PHP file using the exec() command and it does not appear to be working.
I have a file called test1.php that just calls a second file test2.php to run in the background.
exec ("/usr/bin/php -f /path/to/test2.php > /dev/null &");
test2.php just sends out an email to me using the mail function. (just a basic function to debug and figure out what's wrong).
If I run test2.php from the command line, it works fine.
php -f /path/to/test2.php - this works fine and I receive the email if I run this in putty.
If I put test2.php in the public_html directory and go to it directly, that also works fine. But when I try to call it from another PHP file using exec(), nothing happens.
Also, if I call a basic linux command or another program such as ffmpeg using exec() that all works fine. It just appears to be calling a php file. Some google searching has suggested it could be an issue with the php or apache user being set to NOONE and not having permissions. But I'm not sure about that, or what the best solution is if that's the case.
This is on a dedicated linux server. Centos 4.7 PHP 5.2.6 safe_mode = Off
Let me know what other info would be helpful.