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
  • tejas

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

    ini_set(‘max_execution_time’, 0);

  • http://www.mitrastudios.com mitran

    will it work for all???

  • bajick

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

  • http://firsttube.com 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.

  • http://mobiland.az 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