Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-21-2007, 05:54 PM
|
#1
|
|
Member
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 517
Rep:
|
Cron job or Sleep timer??? Which is best in my situation
Well basically, firstly the question is i was looking into a cron job running every so many seconds, but it seems the best available i can see is every minute, unless there is a way to do it??? say if possible show me an example of setting a cron job for something that runs every 20 seconds.
OR
At the moment in my scripts i just use a sleep timer to cause the required delay, and then let it loop basically.
What i want to know is what would cause the greater over heads (CPU wise) and be the most reliable.
A cron job that executes every 20 seconds and then the script exits, or a script in a constant loop that will just sleep for 20 seconds?? Does the sleep command use any overheads or is it more like the command isn't in execution anyway?
Thanks for any info
Mark
Karoshi Team
|
|
|
|
07-21-2007, 05:59 PM
|
#2
|
|
Member
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938
Rep:
|
First, I'm fairly sure that the cron job would take more overhead than the simple sleep loop.
Second, if the job is being run once every 20 seconds, the difference in overhead won't matter at all.
Third, if the interval itself is critical, don't sleep for 20 seconds, but sleep for as long as it takes to start the job 20 seconds after the last time it started.
Fourth, when I read the man page for crontab I don't see any granularity finer than one minute.
Hope this helps.
|
|
|
|
07-21-2007, 06:08 PM
|
#3
|
|
Member
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 517
Original Poster
Rep:
|
Excelent thanks, i got asked to change my already sleep timed scripts to be put into cron, couldn't see much point in it myself wanted to make sure it didn't matter much
Cheers
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:04 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|