Increase a PHP scripts execution time limit

23 March 2009| 2 Comments| Print

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

Share:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Google Bookmarks
  • DZone
  • Reddit
  • Netvibes

2 Comments

  • AzeriFire

    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

  • Adam S

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

Leave a comment...

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

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

This is a Gravatar-enabled site. To get your own globally-recognized-avatar, register at Gravatar.

Your Ad Here