ayevol Posted June 18, 2009 Share Posted June 18, 2009 Hello, I have two questions which I hope you will be able to answer. 1] Does a php script that sleeps for x seconds (continue to) consume server CPU while sleeping? 2] Is having a cronjob which executes a php file every minute very CPU consuming (in which the PHP file itselfs runs for 60 seconds with 30 seconds of total sleep time)? Thank you in advance. Regards, ~Ayevol Quote Link to comment https://forums.phpfreaks.com/topic/162771-solved-cronjob-and-php-sleep/ Share on other sites More sharing options...
RussellReal Posted June 18, 2009 Share Posted June 18, 2009 depends on the operations, I don't really think when php sleeps it uses the CPU Usage alot, but I've never tested that theory, but it shouldn't. but, you'd be doing php for 720 minutes a day lol and in those 30 seconds it MIGHT be a little laggy... BUT I've run a php server script which runs itself into an infinate loop and ran that for weeks at a time and still no lag, so its really up to you if you wanna try it. just if you're gonna be sending mail mail mail mail mail for 30 seconds.. that might kill your server or even get your hosting plan terminated. Quote Link to comment https://forums.phpfreaks.com/topic/162771-solved-cronjob-and-php-sleep/#findComment-858964 Share on other sites More sharing options...
ayevol Posted June 18, 2009 Author Share Posted June 18, 2009 Hey! Thankss for your reply. Would it be a problem for my host if I set up a cronjob which runs 24/7 each minute executing a 30 seconds running PHP script (without sending emails)? Regards, ~Ayevol Quote Link to comment https://forums.phpfreaks.com/topic/162771-solved-cronjob-and-php-sleep/#findComment-859113 Share on other sites More sharing options...
RussellReal Posted June 18, 2009 Share Posted June 18, 2009 you would probably want to contact your web hosting technical support b4 you try it, but I don't see why not, you might want to set the script maximum execution time to 30 seconds to ensure you don't go over 30 seconds.. but I think it defaults to 30 seconds anyway Quote Link to comment https://forums.phpfreaks.com/topic/162771-solved-cronjob-and-php-sleep/#findComment-859122 Share on other sites More sharing options...
ayevol Posted June 19, 2009 Author Share Posted June 19, 2009 Hey, Thanks alot, I have answers to my question. ~Ayevol Quote Link to comment https://forums.phpfreaks.com/topic/162771-solved-cronjob-and-php-sleep/#findComment-859439 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.