I am trying to run a PHP script to run in the background using the exec () function, but I cannot get it to work. I read countless posts about stack overflows and other forums and tried many options to no avail.
Server Information:
Operating System: Linux PHP: 5.2.17 Apache Version: 2.2.23 Home Directory: /home1/username
I am currently using the code:
exec("/home1/username/php /home1/username/public_html/myscript.php > /dev/null &");
When I run the above script, I don't get error_log and no errors in my cPanel error log, however the script is definitely not executing. When I browse http://www.mydomain.com/myscript.php it starts up and instantly sends me an email. Any idea why this is not working / how can I find out what error is occurring?
CPanel Process Manager Output Update
exec("php /home1/username/php /home1/username/public_html/myscript.php > /dev/null &");
It produces:
27183 php /home1/username/php /home1/username/public_html/myscript.php 27221 [sh] 27207 php /home1/username/php /home1/username/public_html/myscript.php 27219 php /home1/username/php /home1/username/public_html/myscript.php 27222 php /home1/username/php /home1/username/public_html/myscript.php 27224 php /home1/username/php /home1/username/public_html/myscript.php 27249 sh -c php /home1/username/php /home1/username/public_html/myscript.php > /dev/null &
This is normal? The script seems to twitch for a long time, although it should run very fast.
source share