Re: limit in a loop function to prevent server load

From: Date: Fri, 06 Sep 2002 00:57:47 +0000
Subject: Re: limit in a loop function to prevent server load
Groups: php.general 
Request: Send a blank email to php-general+get-115380@lists.php.net to get a copy of this message
>hi there i was wondering if there was a way to limit the ammount of items in >a loop to execute sleep then execute the rest of the items to prevent server >load ? http://php.net/sleep Note that "sleep" time doesn't count, but that if your program uses up *TOO* much time, it will be killed by PHP. The default setting is 30 seconds. You can alter it in php.ini or using http://php.net/set_time_limit If you want to sleep 10 seconds every 50 items it would be like this: $count = 0; while (...){ $count++; if (($count % 50) == 0){ sleep(10); } } -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#115380) next »