Sleep Function

From: Date: Mon, 03 Nov 2003 06:48:55 +0000
Subject: Sleep Function
Groups: php.general 
Request: Send a blank email to php-general+get-168376@lists.php.net to get a copy of this message
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 (#168376) next »