time limit

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
pppswing
Forum Commoner
Posts: 33
Joined: Thu Jun 10, 2004 2:04 am
Location: Tallinn, Estonia

time limit

Post by pppswing »

Hi,

I have a trouble of time limit. :?

I have a script that is calling a class and this class is making a giant loop.
it has to process thousands of rows in a database.

The problem is that when i put set_time_limit(5000) in the script, it doesn't seems to work.
Anyway it's doing only about 300 seconds max.

How can I force my script to run longer than 300 seconds ? :roll:

Do I have to put set time in the while loop ?

Maybe there is something to prevent loop to execute more than 300 s in order to prevent infinite loop.

Thanks
:)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Are you sure that it's not just running infinitely? Have you tried limiting the amount of tables that it processes to see if it works?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

You might need to make usage of ini_set('max_execution_time', 28923724798238932)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You might also be using up all allowable memory as well. Are you checking your error logs to see what PHP is telling you? Or are there errors coming to the screen?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

ini_set('max_execution_time', 0);
// or
set_time_limit(0);
If the code that is looping is including a file using include or require it's going to crash. If this is the case a hackjob would be to use require_once, although I would rewrite the code.
Post Reply