I have a php script which needs to run in the background. Currently on my dev box I am running
shell_exec("php5-cgi <path>");
It works fine. Although, when I pushed my code onto a dedicated phpfog cloud, it seem that the script is not being called. I am unable to find out where the issue is. Is it that exec_shell is not working or php5-cgi command does not exist.
How can I understand better what is going on ?
You might try dropping 5-cgi
from your exec call:
exec_shell("php <path>");
Additionally, you could use a cron job for this: http://docs.phpfog.com/customize/cron
Create a cron job to run <path>
on an interval that works for your needs (Assuming path is a php file). PHPFog makes this very easy.
If you are trying to execute a long running task, an not make a browser wait for the result, I recommend queuing in a database table then use a cron job to execute a php script that handles those queued tasks. I would use ajax calls from the client to check the status of the task and then do a page refresh when the task completes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.