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-23-2007, 03:49 AM
|
#1
|
|
Member
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47
Rep:
|
Cron / second precision ?
Hi there!
I'm wondering - CRON entry allows to set up a cron job with minutes, hours, days etc.
But what if i need to do something at 6:23:38 ? I mean, i need second precision?
|
|
|
|
07-23-2007, 04:10 AM
|
#2
|
|
Member
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 292
Rep:
|
Quote:
|
Originally Posted by TrAvIkK
But what if i need to do something at 6:23:38 ?
|
I don't know if cron can be relied upon to always start jobs at the full minute. If it can, then adding your job as
Code:
23 6 * * * sleep 38 && myjob
should do the trick.
|
|
|
|
07-23-2007, 04:16 AM
|
#3
|
|
Member
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47
Original Poster
Rep:
|
Yeah, but sleep 38 means processor usage by 38 sec?
If yes, that is not the answer i was expecting on. I need to take carve about processor usage.
|
|
|
|
07-23-2007, 04:56 AM
|
#4
|
|
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113
Rep: 
|
Quote:
|
Originally Posted by rupertwh
I don't know if cron can be relied upon to always start jobs at the full minute.
|
My cron jobs always start after the minute, and not precisely - at least 9 out of 10 times it's :01, with the rest being :02. I wouldn't be surprised if on a more heavily loaded system it would vary more and sometimes run later.
Quote:
|
Originally Posted by TrAvIkK
Yeah, but sleep 38 means processor usage by 38 sec?
|
Sleep uses no (or virtually no) CPU.
/me wonders what cron job could require second precision, though. 
|
|
|
|
07-23-2007, 05:20 AM
|
#5
|
|
Member
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47
Original Poster
Rep:
|
Hmm what job?
Well, i'm a developer of Web-Based MMO, and some operation (as Battle calculations etc.), which calculating them by users interaction would take too much time.
|
|
|
|
07-23-2007, 01:10 PM
|
#6
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
Cron is not intended for high-accuracy timing. It CAN be and is frequently off by several seconds (due to process start-up, etc.). If you need that kind of precision, I suggest running a daemon of your own to avoid process start-up overhead.
|
|
|
|
07-23-2007, 02:15 PM
|
#7
|
|
Member
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47
Original Poster
Rep:
|
Quote:
|
Originally Posted by Matir
Cron is not intended for high-accuracy timing. It CAN be and is frequently off by several seconds (due to process start-up, etc.). If you need that kind of precision, I suggest running a daemon of your own to avoid process start-up overhead.
|
How to do such thing?
Coz I think i like it
I mean, i know I have to write it by my own (well, as for now - i'm onyl learning C++, so it could be kind of hard :P), but may be there are on internet some examples?
Last edited by TrAvIkK; 07-23-2007 at 02:24 PM.
|
|
|
|
07-23-2007, 03:08 PM
|
#9
|
|
Member
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47
Original Poster
Rep:
|
Quote:
daemonize();
while(1) sleep(1); /* run */
|
Well, so that is the continously handler ^^
|
|
|
|
| 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 07:25 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
|
|