Jump to content

PHP background scripting


sklein99

Recommended Posts

I have a PHP script which needs to run in the background (it invokes 3rd party web services which take several seconds to respond).  I've tried (among other things) to use an exec call:

 

$sitePath = $siteConfig['sitePath'];

$exec_cmd = "/usr/bin/php ".$sitePath."/quote/quotePricing.php > /dev/null 2>&1 &";

exec($exec_cmd);

 

I've tested the called script stand alone (it does a simple DB insert for now for testing) and it works fine, but it does not work when called with exec.

 

In general, I can't seem to get my script to exec another PHP script - I've tried other Unix commands and they work fine (e.g. ls -l).

 

How can I troubleshoot this further?  When I remove the redirection and background execution, my calling script just blocks.  I tried redirecting errors, but the resulting file is empty (e.g. 2>/tmp/errortext.txt).

 

Thanks

Steve

Link to comment
https://forums.phpfreaks.com/topic/145925-php-background-scripting/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.