Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've got two reasons to use a sleep function: first, to automatically send a confirmation email to a client 20 minutes after they contact us. I don't want to use cron jobs because I want it to be exactly 20 minutes (and I'm sick of my web server sending me emails telling me they initiated a cron job.....a new email every 20 minutes!)

Second reason: I've heard of people sending out mass emails using the sleep function. Since my server will only allow 100 emails an hour, I want to use the sleep function to have the script sleep for an hour then continue where it picked up.

My question is this: does it use server resources? Will it slow things down? Are there any other problems with using the sleep function? Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
325 views
Welcome To Ask or Share your Answers For Others

1 Answer

While a process is sleeping it will not consume CPU time, but the process' working set still requires physical memory and/or pagefile to support that process. In other words, the PHP interpreter process needs to keep running. So long as your server has enough RAM this shouldn't be a problem though.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...