Sleep Function

This is a discussion on Sleep Function within the PHP General forums, part of the PHP Programming Forums category; The php.net documentation for the sleep and usleep functions has me confused. I'm using shared hosting and I ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-03-2003
Glenn Gasner
 
Posts: n/a
Default Sleep Function

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
Reply With Quote
  #2 (permalink)  
Old 11-03-2003
Marek Kilimajer
 
Posts: n/a
Default Re: [PHP] Sleep Function

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
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:07 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0