Use your left/right keys to browse tutorials
Increase a PHP scripts execution time limit

Increase a PHP scripts execution time limit

1 Star2 Stars3 Stars4 Stars5 Stars
Posted on March 23, 2009

I’m working on a project right now that uses a PHP crontab to run a heavy script, and the problem I faced was the server kept timing out because by default PHP has a time limit for script execution.

There’s an easy way around this by adding the following line of code to the top of your php code. It simply overrides the maximum execution time for the script.

ini_set('max_execution_time', 600); //600 seconds, you can change this to what ever you like


More tutorials from Papermashup
Comments
5 discussions around Increase a PHP scripts execution time limit
  1. tejas says:

    You can change maximum execution time to unlimited using this code:

    ini_set(‘max_execution_time’, 0);

  2. mitran says:

    will it work for all???

  3. bajick says:

    Thank you very much!!! Keep up the good work!!!

  4. Adam S says:

    Also note that your server admin can disable this ability, so you’ll want to check if it works before relying upon it.

  5. AzeriFire says:

    I like that you are sharing every trick, every helpful code and etc.. That is good :) Thanks for it.
    Your trick also possible with line at .htaccess

    php_value max_execution_time 600





Never miss an update from Papermashup

Get notified about the latest tutorials and downloads.

Subscribe by Email

Get alerts directly into your inbox after each post and stay updated.
Subscribe
OR

Subscribe by RSS

Add our RSS to your feedreader to get regular updates from us.
Subscribe

Get in contact

Please use the form below to get in contact. If your question is related to a free script download, please use the comments on the article page as community members are more likely to respond quicker than I can personally.

About Me

I'm Ashley Ford, Co-founder and Technical Director at Harkable.com London, UK. Previously I worked at InMobi, Spotify and MySpace. My interests include photography and making short videos I'm also an avid F1 fan. I'm always working on side projects. Here are a few: Easy Poll, We Deliver.



What do you specialise in?

I spend a lot of time coding in PHP and MySQL, as well as front end XHTML and CSS. I also specialise in javascript and the jQuery framework as well as being an avid designer. You can find me on dribbble

Interested in advertising?

If you'd like to advertise on Papermashup.com please get in touch via the contact link below for advertising opportunities.

How do I contact you

You can contact me here. and I'm available for consultation, freelance, programming book reviews.

Get on the mailing list

Join over 3000 people who have subscribed to the Papermashup inbox message, and be the first to find out about tutorial, competitions and giveaways.