Re: Sleep Function

From: Date: Mon, 03 Nov 2003 08:44:18 +0000
Subject: Re: Sleep Function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-168379@lists.php.net to get a copy of this message
It is exactly what you need. And you can lower the sleep time, I think 1 or 2 seconds are just enough. Glenn Gasner wrote:
The php.net documentation for the sleep and usleep functions has me confused. I'm using shared hosting and I need to email my whole mailing list while not clogging the shared mail server. What I'm trying to do is put a pause between each email sent (like 10 seconds) so I can set it up to send a thousand (or whatever) messages without manually putting time between batches. My guess is that I should put a line with sleep(10); inside the mail sending loop so that it pauses between notes. However, the Jan-17 note on the usleep function mentions that these kinds of loops can consume 100% of CPU while running. The Jan-29 note on the time() function says that sleep uses way less CPU than wait(). I don't know how to test CPU usage of any PHP function. Is sleep() really so CPU intensive that I should avoid it, is there a better function to use, or is it exactly what I need and it'll be no problem even on a shared server? Thanks! Glenn Gasner glenn at perex dot com


« previous php.general (#168379) next »