Re: PHP Program Randomly Stops
From: Andy Hassall (andy_at_andyh.co.uk)
Date: 05/29/04
- Next message: Pedro Graca: "Re: How should I go about validating a large form that has a "grid" of input fields and check boxes?"
- Previous message: Charlie-Boo: "PHP Program Randomly Stops"
- In reply to: Charlie-Boo: "PHP Program Randomly Stops"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 May 2004 21:10:27 +0100
On 29 May 2004 12:45:11 -0700, chvol@aol.com (Charlie-Boo) wrote:
>I have written a PHP program to retrieve the HTML of web pages, using
>class SNOOPY http://sourceforge.net/projects/snoopy to translate the
>URL into the HTML. After about 100-300 references to snoopy, which
>takes about 5-15 minutes, it stops.
OK, if you have a script that runs for that long, it's inappropriate for it to
be run within a single HTTP request.
>Who knows how to do any of the following (1-3)?
>
>1. "You're going to want to run it not through the web server, but via
>the command line."
http://uk.php.net/manual/en/features.commandline.php
For a script that takes 15 minutes, this by far the preferred method.
>2. "You can use a combination of PHP with client side code to keep the
>script running. Set a particular number of pages to be processed, a
>number lower than when you experience the timeout. As long as there
>are pages to be processed print a client side script, e.g. JavaScript,
>to reload the page. This will reload until all pages are done - then
>don't output the reloader code."
Ugh.
>3. "You are running the script from a browser. The browser receives
>output from your PHP script - or waits for it. Send output to the
>browser that triggers the reloading of the page. This makes sense when
>you invoke (whatever snoopy is) the class a finite number of times,
>e.g. 100 URLs at a time. Once the URLs are processed keep track of
>the number of processed URLs via a session variable. Then output some
>JavaScript to the browser that reloads the page. Here's an example
>How do I "print" a client side script?{: print
>"<script>document.location.reload();</script>"; Alternatively you can
>do it in PHP if you make sure there is no output sent before
>redirecting. You could use the header() function to redirect the
>script to itself. header("Location: ".$_SERVER['PHP_SELF']);"
Sounds like a perversion of what HTTP is meant for, but possibly workable as a
last resort. Unnecessarily complicated though; just go for (1).
-- Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
- Next message: Pedro Graca: "Re: How should I go about validating a large form that has a "grid" of input fields and check boxes?"
- Previous message: Charlie-Boo: "PHP Program Randomly Stops"
- In reply to: Charlie-Boo: "PHP Program Randomly Stops"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|