Page 1 of 1

max execution time

Posted: Mon May 03, 2010 5:04 pm
by fredass
Hi.
the situation is this: I need to execute code that finishes job for example after 5 min., but the php max_execution_time is set to 45s. and I can't change it because it's on dedicated server. After 45s. of executing code I get an error: "mod_fcgid: read data timeout in 45 seconds". The questions is - what is the best solution for bypassing this error? And after an error I need to execute code from the place it stoped working... Is it possible to catch server errors in php code?
Need your opinion and experience!

Thanks

Re: max execution time

Posted: Mon May 03, 2010 5:33 pm
by Christopher
What are you doing that takes 5 minutes? PHP is not meant for long running programs because it runs inside the web server.

Re: max execution time

Posted: Mon May 03, 2010 5:37 pm
by DaveTheAve
Sounds like a simple one-liner fix:

Code: Select all

set_time_limit(0);
(Place after <?php)

Re: max execution time

Posted: Mon May 03, 2010 5:54 pm
by fredass
Christopher wrote:What are you doing that takes 5 minutes? PHP is not meant for long running programs because it runs inside the web server.
I need to download some info from other website and store it in my database. It doesnt take 5 min. It was for example. My code needs about 1-2 min.
Also tried: set_time_limit(yourlimit); and ini_set('max_execution_time',yourlimit); but server providers doesnt allow to change php.ini

Re: max execution time

Posted: Mon May 03, 2010 6:15 pm
by DaveTheAve
No way to fix it then. You have to be able to change set_time_limit(0); to make it work. :(

Re: max execution time

Posted: Tue May 04, 2010 4:22 am
by fredass
thats bad.. maybe it is possible to catch internal server errors in php? it would make it much easer..