Papermashup

Subscribe


Tweets


"RT @Eva_Shaughnessy: #finedining @romomobilecafes restaurant this evening with #NewHair #winning #SaturdayNight #GirlsNightOut http://t.co/…"

@ashleyford 3 weeks ago

"RT @kycutwilson: @ashleyford @burgerbeartom incredible. There's 5 more left! Shout about it!!"

@ashleyford 4 weeks ago

Designer and web developer, Co-founder and Technical Director at Harkable.com. Previously I worked at Spotify, MySpace and InMobi. Contact me - ashley[at]papermashup.com

Increase a PHP scripts execution time limit

AshleyAshley

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

Designer and web developer, Co-founder and Technical Director at Harkable.com. Previously I worked at Spotify, MySpace and InMobi. Contact me - ashley[at]papermashup.com

Comments 5
  • tejas
    Posted on

    tejas tejas

    Reply Author

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

    ini_set(‘max_execution_time’, 0);


  • mitran
    Posted on

    mitran mitran

    Reply Author

    will it work for all???


  • bajick
    Posted on

    bajick bajick

    Reply Author

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


  • Adam S
    Posted on

    Adam S Adam S

    Reply Author

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


  • AzeriFire
    Posted on

    AzeriFire AzeriFire

    Reply Author

    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