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. #2
    Master Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    5,202
    Thanks
    114
    Thanked 614 Times in 600 Posts
    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.
    Quote Originally Posted by deathshadow View Post
    So seriously, loosen up that tie, let out the belt, and try relating to normal people on the street instead of the gentleman's club crowd.

  3. #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. #4
    Master Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    5,202
    Thanks
    114
    Thanked 614 Times in 600 Posts
    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).
    Quote Originally Posted by deathshadow View Post
    So seriously, loosen up that tie, let out the belt, and try relating to normal people on the street instead of the gentleman's club crowd.


 

Posting Permissions

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