LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 12-07-2005, 11:38 AM   #1
AdmiralFreezbee
LQ Newbie
 
Registered: Mar 2005
Posts: 12

Rep: Reputation: 0
use of sleep


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 ?

This script needs to be run in the background
 
Old 12-07-2005, 12:11 PM   #2
fouldsy
Senior Member
 
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
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.
 
Old 12-07-2005, 12:54 PM   #3
AdmiralFreezbee
LQ Newbie
 
Registered: Mar 2005
Posts: 12

Original Poster
Rep: Reputation: 0
the thing I need to execute is a nsupdate do update the record on my DNS server
 
Old 12-07-2005, 01:21 PM   #4
fouldsy
Senior Member
 
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
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?
 
Old 12-07-2005, 01:34 PM   #5
AdmiralFreezbee
LQ Newbie
 
Registered: Mar 2005
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 12-07-2005, 02:27 PM   #6
fouldsy
Senior Member
 
Registered: Jan 2002
Location: St Louis, MO
Distribution: Ubuntu
Posts: 1,284

Rep: Reputation: 47
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?
 
Old 12-08-2005, 10:53 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,665
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
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...
 
Old 12-09-2005, 02:32 AM   #8
AdmiralFreezbee
LQ Newbie
 
Registered: Mar 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sundialsvcs
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.
 
  


Reply



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 On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching for Server (BOOTP/DHCP) <sleep> <sleep> .. .. Eileen Linux - Networking 12 10-21-2005 01:14 AM
Sleep Samoth Linux - General 1 05-01-2005 06:20 PM
sleep TroelsSmit Linux - Newbie 10 05-22-2004 01:17 AM
sleep liguorir Linux - Software 1 08-10-2003 03:53 PM
to sleep or not hejduk Linux - General 3 03-28-2002 03:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration