Results 1 to 9 of 9
  1. #1

    Extending Max Execution Time

    I am trying to run a php script on our server to split a very large file. As a result of the file size the script is timing out with this error:

    Fatal error: Maximum execution time of 30 seconds exceeded in /home/mydomain.com/script/ on line 155

    How can I extend the server execution time to the script can complete? I have cpanel with WHM installed.

    Thanks

  2. #2
    Join Date
    Jan 2007
    Location
    /dev/null
    Posts
    3,700
    http://php.net/set_time_limit

    You could set it to 0 and it will never happen again (check your php.ini file for max_execution_time)
    Last edited by Robert vd Boorn; 05-27-2009 at 07:48 PM.

  3. #3
    Quote Originally Posted by Rob B View Post
    http://php.net/set_time_limit

    You could set it to 0 and it will never happen again.
    Rob

    Thanks, where do I do this within the script OR server?

  4. #4
    Join Date
    Jan 2007
    Location
    /dev/null
    Posts
    3,700
    You would have to edit your php.ini file;
    On linux you could just do find php.ini and edit it:
    PHP Code:
    ;;;;;;;;;;;;;;;;;;;
    Resource Limits ;
    ;;;;;;;;;;;;;;;;;;;

    max_execution_time 30     Maximum execution time of each scriptin seconds
    max_input_time 
    60     Maximum amount of time each script may spend parsing request data
    ;max_input_nesting_level 64 Maximum input variable nesting level
    memory_limit 
    128M      Maximum amount of memory a script may consume (128MB

  5. #5
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,771
    To get the path to the php.ini file use below.

    php -i | grep php.ini
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  6. #6
    If the hosting env is shared and you can't edit php.ini you should contact your support.
    Ivan V, technical support
    Landis Holdings, Inc - Power, Speed, Reliability
    Reseller, shared, VPS, Dedicated hosting
    http://hostingzoom.com/

  7. #7
    Join Date
    Jan 2008
    Posts
    84
    If its shared try calling the set_time_limit function in the first line of your php code or before the code that you think is exceding the time limit.

    set_time_limit(int $seconds)

    where $seconds can be zero to remove any limits

  8. #8
    Nice thing JBapt, thanks. I'll keep that function in mind.
    Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.

    danieljj, here is F's description:

    void set_time_limit ( int $seconds )

    When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.
    Ivan V, technical support
    Landis Holdings, Inc - Power, Speed, Reliability
    Reseller, shared, VPS, Dedicated hosting
    http://hostingzoom.com/

  9. #9

    Add this to your htaccess

    Hi there,

    Just add the following line to your .htaccess file, changing the 600 for the amount of seconds you want the limit to be in that directory. (Its set to 600 seconds or 10 minutes in my code)

    php_value max_execution_time 600


    -Beyblade

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •