Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/162771-solved-cronjob-and-php-sleep/
Share on other sites

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.