Re: PHP Program Randomly Stops

From: Andy Hassall (andy_at_andyh.co.uk)
Date: 05/29/04


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


Relevant Pages

  • PHP Program Randomly Stops
    ... "You can use a combination of PHP with client side code to keep the ... are pages to be processed print a client side script, e.g. JavaScript, ... This will reload until all pages are done - then ... "You are running the script from a browser. ...
    (comp.lang.php)
  • Re: Running long script in the background
    ... and forgotten (except for the presence of session cookies). ... timed-redirect (reload) of the same URL with the cookie, ... completely separate transaction starting a new CGI ... script on the server that untars a 600 meg volume, ...
    (comp.lang.python)
  • Re: Please advise on making a linux system service
    ... But most of them also takes restart, reload, ... configuration files without actually terminating. ... script source at the very begining. ... This pid may be needed to signal the ...
    (comp.os.linux.development.system)
  • Re: simple javascript function
    ... Mine does the same (with a different approach - I just don't reload the ... "Jon Spivey" wrote in message ... >>> with script, eg say you had a form like this ... Murray ...
    (microsoft.public.frontpage.programming)
  • Re: reload rc.conf during boot process
    ... reload rc.conf during boot process ... |> I was just looking at that diff you attached. ... |> nothing matches, i.e if the script isn't called selectcf, then it'll ... to actually run my selectcf script? ...
    (freebsd-questions)