LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 07-23-2007, 03:49 AM   #1
TrAvIkK
Member
 
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47

Rep: Reputation: 15
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?
 
Old 07-23-2007, 04:10 AM   #2
rupertwh
Member
 
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 297

Rep: Reputation: 49
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.
 
Old 07-23-2007, 04:16 AM   #3
TrAvIkK
Member
 
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47

Original Poster
Rep: Reputation: 15
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.
 
Old 07-23-2007, 04:56 AM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
Old 07-23-2007, 05:20 AM   #5
TrAvIkK
Member
 
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47

Original Poster
Rep: Reputation: 15
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.
 
Old 07-23-2007, 01:10 PM   #6
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
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.
 
Old 07-23-2007, 02:15 PM   #7
TrAvIkK
Member
 
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47

Original Poster
Rep: Reputation: 15
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.
 
Old 07-23-2007, 02:25 PM   #8
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Write a daemon (basically any continuously-running application) that handles the updates you need.

http://www.google.com/search?q=daemo...ient=firefox-a
 
Old 07-23-2007, 03:08 PM   #9
TrAvIkK
Member
 
Registered: May 2006
Distribution: Lovley Debian etch :)
Posts: 47

Original Poster
Rep: Reputation: 15
Quote:
daemonize();
while(1) sleep(1); /* run */
Well, so that is the continously handler ^^
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM
Dell Precision 670? etcetera Linux - Hardware 11 03-20-2006 09:34 PM
C- precision problem vivekr Programming 30 01-13-2006 11:43 AM
fortran 77 precision buddy_epson Programming 0 07-19-2003 03:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:38 PM.

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