Increase a PHP scripts execution time limit

Posted on March 23, 2009 by Ashley

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
This entry was posted in PHP, Tutorials and tagged , . Bookmark the permalink.
Comments
3 discussions around Increase a PHP scripts execution time limit
  1. 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

  2. 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.

  3. bajick says:

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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribers
1,250
Twitter
510
Comments
1,207
Posts
125