Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need some script that needs to do some work every 10 seconds. To do this I wrote
sleep 10
echo "do something"
Now I'm getting the feeling that this slows my system down. I guess that's because the sleep process still needs processing time to do nothing. Is this true? And if so what is a better way to do this ?
Depending on what you're getting the system to do in terms of closing down processes once finished, it shouldn't be that much of a problem, but what is you need executing every 10 seconds? A more elegant solution would be to execute your script via cron, but the lowest interval would be every minute, I don't think you can specify it to run every x seconds.
Do you really need your client updating every 10 seconds? I think a cronjob running every minute might be more reasonable, maybe not even that often... What is it you have running on your machine that requires such frequent communication with your DNS server?
I realise it sounds a bit like overkill (well a lot) but I have my reasons. It all fits in one application that needs high performance and can't be down for more than 20 seconds.
Okay, so a backgrounded script is about all I can think of at those intervals, though I still don't understand your environment. nsupdate shouldn't cause any memory leaks that would build up + up causing the system to slow down.
Could you elaborate a little more on what you mean when you say the system slows down, and also include the script you've written, along with how you're starting this script?
If you want ten-second resolution, I think that what you are doing now is reasonable: one process (group), that continues to exist, that sleeps at regular intervals.
When a process "sleeps," it simply becomes non-dispatchable for ten seconds. When the timer interrupt goes off, the process gets placed on the runlist again. There's no overhead in doing that. It isn't "slowing the system down."
It would actually be slightly more expensive to rely upon cron, because a new process is constantly being created, every ten seconds. That's unnecessary here, imho...
If you want ten-second resolution, I think that what you are doing now is reasonable: one process (group), that continues to exist, that sleeps at regular intervals.
When a process "sleeps," it simply becomes non-dispatchable for ten seconds. When the timer interrupt goes off, the process gets placed on the runlist again. There's no overhead in doing that. It isn't "slowing the system down."
It would actually be slightly more expensive to rely upon cron, because a new process is constantly being created, every ten seconds. That's unnecessary here, imho...
Thanks for your answers. I guess the slowing down must have another reason.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.