Web Analytics Made Easy -
StatCounter Avoid PHP script timeout - CodingForum

Announcement

Collapse
No announcement yet.

Avoid PHP script timeout

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Avoid PHP script timeout

    All,
    I have a script that will basically be a web crawler and I want it to run for a long time obviously to do the crawling. What are best approaches so the script doesn't timeout? If I'm running this on my local machine can I do it as a cron job? Thank you for your suggestions.

  • #2
    set_time_limit(0);

    Yes you can run any php script via a scheduling system but you'll need to look up the various parameters / switches that need to be passed via the command line. Alternatively you could use a service like setcronjob to make a http call to your script - using ignore_user_abort(true) to ensure the script continues executing after the http client disconnects.
    "Tango says double quotes with a single ( ' ) quote in the middle"
    '$Name says single quotes with a double ( " ) quote in the middle'
    "Tango says double quotes ( \" ) must escape a double quote"
    '$Name single quotes ( \' ) must escape a single quote'

    Comment


    • #3
      Thanks, if I'm using the XAMPP locally on my computer, does it have anything in it to run the cronjob or would I just have to set the set_time_limit(0); in my php.ini file and execute the script?

      Comment


      • #4
        Scriptwise just set_time_limit() but as i've said previously you need to checkout the command line options yourself. I don't know what cron system xampp uses as I don't use xampp (compared to uniformserver it takes up far too much diskspace).
        "Tango says double quotes with a single ( ' ) quote in the middle"
        '$Name says single quotes with a double ( " ) quote in the middle'
        "Tango says double quotes ( \" ) must escape a double quote"
        '$Name single quotes ( \' ) must escape a single quote'

        Comment

        Working...
        X