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 ?

4
  • I'm not familiar with PHPFog, but in Pagoda Box, these are called workers. Not pimping the competition, just giving you my context. Commented Jul 15, 2012 at 23:03
  • What is exec_shell? PHP function? Commented Jul 15, 2012 at 23:08
  • 2
    First you should get familiar with documentation: docs.phpfog.com/faqs/#sharedvdedicated Commented Jul 15, 2012 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) Commented Jul 16, 2012 at 8:56

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This has almost solved my problem. Only issue now is that. When I run "php <path>" I do not have the apache environment exposed to that script.
You will have the phpfog environment variables when you run the script with the cron job interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.