Re: asynchronous PHP
- From: "Álvaro G. Vicario" <alvaroNOSPAMTHANKS@xxxxxxxxxxxxxx>
- Date: Mon, 29 Dec 2008 17:44:02 +0100
Lawrence Krubner escribió:
The server I'm working on right now allows PHP scripts to run for 300 seconds. I need to get around that. I'm writing a script that pings the Google Ajax API. The script is called as a cron job. It needs to make over 100,000 queries against Google.
I thought maybe I could get around the time limit by having the first script call other scripts, like this:
Normally, you can just increase the limit yourself, either in your custom config file on in code itself:
ini_set('max_execution_time', 86400); // 1 day in seconds
However, I remember having read somewhere that the command line SAPI defaults to "unlimited". Most of the time, there's no need to run cron jobs through the web server.
shell_exec("callGoogle1.php");
shell_exec("callGoogle2.php");
shell_exec("callGoogle3.php");
shell_exec("callGoogle4.php");
shell_exec("callGoogle5.php");
But the first PHP scripts waits for shell_exec() to return before making the next call. So how do I break out of the procedural, step-by-step approach that PHP takes? Is there a correct way to do this?
You can probably use some Unix fancy stuff, like:
shell_exec("./callGoogle1.php &");
Or maybe:
shell_exec("nohup ./callGoogle1.php &");
Have a look at this user note:
http://es.php.net/manual/en/function.set-time-limit.php#53564
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
.
- References:
- asynchronous PHP
- From: Lawrence Krubner
- asynchronous PHP
- Prev by Date: Re: Firebug
- Next by Date: constants in heredoc
- Previous by thread: Re: asynchronous PHP
- Next by thread: Re: asynchronous PHP
- Index(es):
Relevant Pages
|