max execution time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fredass
Forum Newbie
Posts: 12
Joined: Tue Apr 06, 2010 4:18 pm

max execution time

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: max execution time

Post 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.
(#10850)
User avatar
DaveTheAve
Forum Contributor
Posts: 385
Joined: Tue Oct 03, 2006 2:25 pm
Location: 127.0.0.1
Contact:

Re: max execution time

Post by DaveTheAve »

Sounds like a simple one-liner fix:

Code: Select all

set_time_limit(0);
(Place after <?php)
fredass
Forum Newbie
Posts: 12
Joined: Tue Apr 06, 2010 4:18 pm

Re: max execution time

Post 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
User avatar
DaveTheAve
Forum Contributor
Posts: 385
Joined: Tue Oct 03, 2006 2:25 pm
Location: 127.0.0.1
Contact:

Re: max execution time

Post by DaveTheAve »

No way to fix it then. You have to be able to change set_time_limit(0); to make it work. :(
fredass
Forum Newbie
Posts: 12
Joined: Tue Apr 06, 2010 4:18 pm

Re: max execution time

Post by fredass »

thats bad.. maybe it is possible to catch internal server errors in php? it would make it much easer..
Post Reply