Re: asynchronous PHP
- From: NC <nc@xxxxxxxxx>
- Date: Mon, 29 Dec 2008 12:01:05 -0800 (PST)
On Dec 28, 11:44 pm, Lawrence Krubner <lawre...@xxxxxxxxxxx> wrote:
The server I'm working on right now allows PHP scripts to run for 300
seconds.
Which PHP scripts? The ones that are handled by the "Web-based" PHP
interpreter (which could be either an Apache module or CGI/FastCGI
executable) or the ones that are handled by the command-line
interpreter (CLI)? The two PHP interpreters running on the same
machine can be configured differently... Moreover, the CLI has
max_execution_time set to 0 (unlimited) by default:
http://php.net/CLI
I need to get around that.
You probably don't, as command-line scripts are normally allowed
to operate indefinitely, unless they overuse CPU and/or bandwidth.
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.
How often? Weekly, daily, hourly? The reason I am asking is,
HTTP connections are not established instantaneously. I had a
project where I had to repeatedly ping Yahoo! and I found that
a ping from my ISP's server took about 0.2 seconds on average.
If your situation is similar to mine, your script should take
about six hours to run...
Assuming you need this done daily or less often, here's what
you can do. Write a script that does only a small chunk of
work (say, 100 pings), but remembers what it did last (using a
database, for example). Then, schedule this script to run
every 10 minutes (or every three minutes between midnight and
5 AM).
Cheers,
NC
.
- References:
- asynchronous PHP
- From: Lawrence Krubner
- asynchronous PHP
- Prev by Date: Re: Query String
- Next by Date: ldap_bind issues
- Previous by thread: Re: asynchronous PHP
- Next by thread: Firebug
- Index(es):
Relevant Pages
|