0

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 ?

Prakash Raman
  • 13,319
  • 27
  • 82
  • 132
  • I'm not familiar with PHPFog, but in [Pagoda Box, these are called workers](http://help.pagodabox.com/customer/portal/articles/430779). Not pimping the competition, just giving you my context. – Jared Farrish Jul 15 '12 at 23:03
  • What is `exec_shell`? PHP function? – Gabriel Santos Jul 15 '12 at 23:08
  • 2
    First you should get familiar with documentation: http://docs.phpfog.com/faqs/#sharedvdedicated – dev-null-dweller Jul 15 '12 at 23:10
  • JaredFarrish: Thanks looking at it :) GabrielSantos: Yes, it is a PHP fuction. @dev-null-dweller: I have read it, it does not say anything on how to call a php script using any of the functions though. Just says that they are available in a dedicated sever (which I have) – Prakash Raman Jul 16 '12 at 08:56

1 Answers1

1

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.

Tim Santeford
  • 27,385
  • 16
  • 74
  • 101