PHP Program Randomly Stops

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charlie-Boo

    PHP Program Randomly Stops

    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."

    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."

    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>docume nt.location.rel oad();</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("Locatio n: ".$_SERVER['PHP_SELF']);"

    Explanation:

    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.

    1. I start it using Internet Explorer.
    2. There is no error message.
    3. The program has no reference to set_time_limit.
    4. max_executionti me=0 in php.ini .
    5. A program that simply executes an endless for, periodically
    printing out the current time, runs indefinitely, which I manually
    stopped after 2 hours.
    6. I am running it on my single PC window 98 webserver Apache from
    PHPTriad http://sourceforge.net/projects/phptriad .

    I received the above three answers, but I don't know how to do those
    things. I program only in PHP (and HTML.) I couldn't get any further
    explanation.

    Charlie chvol@aol.com
  • Andy Hassall

    #2
    Re: PHP Program Randomly Stops

    On 29 May 2004 12:45:11 -0700, chvol@aol.com (Charlie-Boo) wrote:
    [color=blue]
    >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.[/color]

    OK, if you have a script that runs for that long, it's inappropriate for it to
    be run within a single HTTP request.
    [color=blue]
    >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."[/color]



    For a script that takes 15 minutes, this by far the preferred method.
    [color=blue]
    >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."[/color]

    Ugh.
    [color=blue]
    >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>docum ent.location.re load();</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("Locatio n: ".$_SERVER['PHP_SELF']);"[/color]

    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

    Comment

    Working...