Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 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
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,304
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Regular Coder
    Join Date
    Oct 2009
    Posts
    438
    Thanks
    9
    Thanked 7 Times in 7 Posts
    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?

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,304
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    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).
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •