Code execution Time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • UKuser

    #1

    Code execution Time

    Hi,

    I have the following script which I'm using to verify that websites
    exist. However in either FF or IE it only runs for about 60 seconds.
    I've changed what ini settings I think affect it, but to no avail. Can
    you tell me how to make it run for longer. I could have quite a few
    hundred sites and I simply want to make sure they return OK.

    The code will work as is but you'll see it probably won't do quite a
    long list. (stops at about 10).

    Thanks

    A

    <?php
    ini_set('max_ex ecution_time',9 99);
    ini_set('max_in put_time',999);

    if (!(isset($_POST['sites']))){
    print "<form method=\"post\" action=\"test2. php\"><textarea name=
    \"sites\" rows=25 cols=25></textarea><input type=\"submit\" ></form>";
    } else {

    $sites = split("\r\n",$_ POST['sites']);

    foreach ($sites as $path){

    $http_response_ header = array(); // clear arrays in case previous
    data still held
    $file = array();
    $file = @file_get_conte nts("http://$path");

    if (!(is_numeric(s trpos($http_res ponse_header[0],"OK")))){ //
    Is the website NOT ok
    if (is_numeric(str pos($http_respo nse_header[0],"30"))){ //
    Has it been redirected?
    foreach ($http_response _header as $k=>$value){
    $value = str_replace("Co ntent-Location","",$v alue); //
    Strip out the Content tags which confuse issues
    if (is_numeric(str pos($value,"Loc ation"))){ //
    If this one carries the location - use it
    $value = str_replace("Lo cation: ","",$value );
    $http_response_ header = array();
    $file2 = @file_get_conte nts($value); // Connect
    to the forwarded site just to check
    if (!(is_numeric(s trpos($http_res ponse_header[0],"OK"))))
    {
    print "$path <b>IS NOW</b$value<br>";
    } else {
    print "$value redirected but is DEAD<br>";
    }
    }
    }
    } else {
    print "$path is not live<br>";
    }
    } else {
    print "$path is ok<br>";
    }
    }
    }
    ?>
  • ninja

    #2
    Re: Code execution Time

    On Nov 29, 8:45 am, UKuser <spiderc...@yah oo.co.ukwrote:
    Hi,
    >
    I have the following script which I'm using to verify that websites
    exist. However in either FF or IE it only runs for about 60 seconds.
    I've changed what ini settings I think affect it, but to no avail. Can
    you tell me how to make it run for longer. I could have quite a few
    hundred sites and I simply want to make sure they return OK.
    >
    The code will work as is but you'll see it probably won't do quite a
    long list. (stops at about 10).
    >
    Thanks
    >
    A
    >
    <?php
    ini_set('max_ex ecution_time',9 99);
    ini_set('max_in put_time',999);
    >
    if (!(isset($_POST['sites']))){
    print "<form method=\"post\" action=\"test2. php\"><textarea name=
    \"sites\" rows=25 cols=25></textarea><input type=\"submit\" ></form>";
    >
    } else {
    >
    $sites = split("\r\n",$_ POST['sites']);
    >
    foreach ($sites as $path){
    >
    $http_response_ header = array(); // clear arrays in case previous
    data still held
    $file = array();
    $file = @file_get_conte nts("http://$path");
    >
    if (!(is_numeric(s trpos($http_res ponse_header[0],"OK")))){ //
    Is the website NOT ok
    if (is_numeric(str pos($http_respo nse_header[0],"30"))){ //
    Has it been redirected?
    foreach ($http_response _header as $k=>$value){
    $value = str_replace("Co ntent-Location","",$v alue); //
    Strip out the Content tags which confuse issues
    if (is_numeric(str pos($value,"Loc ation"))){ //
    If this one carries the location - use it
    $value = str_replace("Lo cation: ","",$value );
    $http_response_ header = array();
    $file2 = @file_get_conte nts($value); // Connect
    to the forwarded site just to check
    if (!(is_numeric(s trpos($http_res ponse_header[0],"OK"))))
    {
    print "$path <b>IS NOW</b$value<br>";
    } else {
    print "$value redirected but is DEAD<br>";
    }
    }
    }
    } else {
    print "$path is not live<br>";
    }
    } else {
    print "$path is ok<br>";
    }
    }}
    >
    ?>
    Hey there UKUser, Have you considered using the command line binary
    with lib_curl, then piping your output to an html file? I've done that
    with MANY of my automated PHP scripts, with great success and no
    concerns about timeouts. I've a script that can run as long as 2 hours
    doing some data administration tasks from 1AM-3AM local, scheduled
    through cron. Some of the data tasks required involve reading CSV
    feeds from servers other than my own, as well as remote PostgreSQL
    queries. There is another script that builds an HTML report on server
    status and uptimes that's in a FF window with a META refresh tag that
    triggers on 5 minute marks. Hope that gives you some ideas on how to
    get your script doing what you need it to do.

    Good Luck.

    Comment

    • Jerry Stuckle

      #3
      Re: Code execution Time

      UKuser wrote:
      Hi,
      >
      I have the following script which I'm using to verify that websites
      exist. However in either FF or IE it only runs for about 60 seconds.
      I've changed what ini settings I think affect it, but to no avail. Can
      you tell me how to make it run for longer. I could have quite a few
      hundred sites and I simply want to make sure they return OK.
      >
      The code will work as is but you'll see it probably won't do quite a
      long list. (stops at about 10).
      >
      Thanks
      >
      A
      >
      <?php
      ini_set('max_ex ecution_time',9 99);
      ini_set('max_in put_time',999);
      >
      if (!(isset($_POST['sites']))){
      print "<form method=\"post\" action=\"test2. php\"><textarea name=
      \"sites\" rows=25 cols=25></textarea><input type=\"submit\" ></form>";
      } else {
      >
      $sites = split("\r\n",$_ POST['sites']);
      >
      foreach ($sites as $path){
      >
      $http_response_ header = array(); // clear arrays in case previous
      data still held
      $file = array();
      $file = @file_get_conte nts("http://$path");
      >
      if (!(is_numeric(s trpos($http_res ponse_header[0],"OK")))){ //
      Is the website NOT ok
      if (is_numeric(str pos($http_respo nse_header[0],"30"))){ //
      Has it been redirected?
      foreach ($http_response _header as $k=>$value){
      $value = str_replace("Co ntent-Location","",$v alue); //
      Strip out the Content tags which confuse issues
      if (is_numeric(str pos($value,"Loc ation"))){ //
      If this one carries the location - use it
      $value = str_replace("Lo cation: ","",$value );
      $http_response_ header = array();
      $file2 = @file_get_conte nts($value); // Connect
      to the forwarded site just to check
      if (!(is_numeric(s trpos($http_res ponse_header[0],"OK"))))
      {
      print "$path <b>IS NOW</b$value<br>";
      } else {
      print "$value redirected but is DEAD<br>";
      }
      }
      }
      } else {
      print "$path is not live<br>";
      }
      } else {
      print "$path is ok<br>";
      }
      }
      }
      ?>
      >
      If you can change the PHP timeout parameter (some hosting companies let
      you do so, some don't), you're probably running into a browser timeout.

      If so, you might be able to keep the browser from timing out by calling
      ob_flush() and flush() after printing a message. No guarantees - the
      output may still be cached by your server. But then PHP isn't caching
      it, also.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • UKuser

        #4
        Re: Code execution Time

        On 29 Nov, 17:11, Jerry Stuckle <jstuck...@attg lobal.netwrote:
        UKuser wrote:
        Hi,
        >
        I have the following script which I'm using to verify that websites
        exist. However in either FF or IE it only runs for about 60 seconds.
        I've changed what ini settings I think affect it, but to no avail. Can
        you tell me how to make it run for longer. I could have quite a few
        hundred sites and I simply want to make sure they return OK.
        >
        The code will work as is but you'll see it probably won't do quite a
        long list. (stops at about 10).
        >
        Thanks
        >
        A
        >
        <?php
        ini_set('max_ex ecution_time',9 99);
        ini_set('max_in put_time',999);
        >
        if (!(isset($_POST['sites']))){
        print "<form method=\"post\" action=\"test2. php\"><textarea name=
        \"sites\" rows=25 cols=25></textarea><input type=\"submit\" ></form>";
        } else {
        >
        $sites = split("\r\n",$_ POST['sites']);
        >
        foreach ($sites as $path){
        >
        $http_response_ header = array(); // clear arrays in case previous
        data still held
        $file = array();
        $file = @file_get_conte nts("http://$path");
        >
        if (!(is_numeric(s trpos($http_res ponse_header[0],"OK")))){ //
        Is the website NOT ok
        if (is_numeric(str pos($http_respo nse_header[0],"30"))){ //
        Has it been redirected?
        foreach ($http_response _header as $k=>$value){
        $value = str_replace("Co ntent-Location","",$v alue); //
        Strip out the Content tags which confuse issues
        if (is_numeric(str pos($value,"Loc ation"))){ //
        If this one carries the location - use it
        $value = str_replace("Lo cation: ","",$value );
        $http_response_ header = array();
        $file2 = @file_get_conte nts($value); // Connect
        to the forwarded site just to check
        if (!(is_numeric(s trpos($http_res ponse_header[0],"OK"))))
        {
        print "$path <b>IS NOW</b$value<br>";
        } else {
        print "$value redirected but is DEAD<br>";
        }
        }
        }
        } else {
        print "$path is not live<br>";
        }
        } else {
        print "$path is ok<br>";
        }
        }
        }
        ?>
        >
        If you can change the PHP timeout parameter (some hosting companies let
        you do so, some don't), you're probably running into a browser timeout.
        >
        If so, you might be able to keep the browser from timing out by calling
        ob_flush() and flush() after printing a message. No guarantees - the
        output may still be cached by your server. But then PHP isn't caching
        it, also.
        >
        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstuck...@attgl obal.net
        =============== ===
        Just wanted to say thanks guys for both your input. It is a mix of the
        max-executiont time, the socket connection time and the browsers. I'm
        nearly there - and get better results by running my script with php-
        cgi.exe rather than through a browser.

        Many thanks

        A

        Comment

        • AnrDaemon

          #5
          Re: Code execution Time

          Greetings, UKuser.
          In reply to Your message dated Wednesday, December 5, 2007, 19:06:27,
          and get better results by running my script with php-
          cgi.exe rather than through a browser.
          O.o What You mean "running script through a browser"?


          --
          Sincerely Yours, AnrDaemon <anrdaemon@free mail.ru>

          Comment

          Working...