Results 1 to 9 of 9
Thread: Extending Max Execution Time
-
05-27-2009, 07:35 PM #1Newbie
- Join Date
- Mar 2009
- Posts
- 11
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
-
05-27-2009, 07:41 PM #2cout << m_subtitle;
- 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.
-
05-27-2009, 07:48 PM #3Newbie
- Join Date
- Mar 2009
- Posts
- 11
-
05-27-2009, 07:53 PM #4cout << m_subtitle;
- 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 script, in 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)
-
05-28-2009, 03:31 AM #5Web Hosting Master
- 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.iniDavid | www.cliffsupport.com
Affordable Server Management Solutions sales AT cliffsupport DOT com
CliffWebManager | Access WHM from iPhone and Android
-
05-28-2009, 04:50 AM #6Junior Guru Wannabe
- Join Date
- Oct 2008
- Posts
- 72
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/
-
05-28-2009, 05:15 AM #7Junior Guru Wannabe
- 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
-
05-28-2009, 05:21 AM #8Junior Guru Wannabe
- Join Date
- Oct 2008
- Posts
- 72
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/
-
05-28-2009, 12:31 PM #9New Member
- Join Date
- May 2009
- Posts
- 1
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