KBD

Keith Devens .com

Tuesday, December 2, 2008 Flag waving
That which yields, is not always weak. – Jacqueline Carey (Kushiel's Dart)
← CachingAmy Acker is awesome →

Daily link icon Wednesday, May 5, 2004

Cron question

Is there a way to run a cron every 90 minutes? If my cron line is something like:

*/90 * * * *

It runs every 60 minutes. It seems like the minute counter won't let it go above 60. But then how can I run something every hour and a half (or two hours and a half), or every 72 minutes or something?

← CachingAmy Acker is awesome →

Comments XML gif

Drew Csillag (http://idiotic.blogspot.com) wrote:

Well, for 90 minutes, it'd be
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * blahblahblah
30 1,3,5,7,9,11,13,15,17,19,21,23 * * * blahblahblah

For 72 minutes..... mwahahahahaha! ROTFL.... Oh... you were serious?

Alternatively, if the exact timing isn't absolutely required (i.e. if its' 73 or 71 minutes) you could use "recursive" at jobs.

For example:
in file x.at:
....cut here....
python << EOF > nexttime
import time
t = time.localtime(time.time() + (72*60))
print "%02d:%02d" % (t[3], t[4])
EOF
at -f x.at cat nexttime
rm nexttime
periodic_task_program
....cut here....
Then run "at -f x.at now" and that should run the task immediately, and then every 72 minutes. This has, of course, only been cursorararily (if that's a word) tested, so YMMV. It is possible that if your periodic task takes longer than 72 minutes, weird things can happen, but I suspect that if your periodic task takes 72 minutes, weird things have already happened. Smiley

The python script could of course be replaced by any better date computing thing you wish.

Drew

∴ Drew Csillag | 5-May-2004 2:24pm est | http://idiotic.blogspot.com | #4502

Ryan (http://www.trolocsis.com) wrote:

From the man pages, it appears the minute's maximum value in the cron is 59 minutes. Perhaps something like this will work:

30 0,2,4,6,8,10,12,14,16,18,20,22 * * * yourscript
0 1,3,5,7,9,11,13,15,17,19,21,23 * * * yourscript

or maybe 1-23/2 for the hour field

∴ Ryan | 5-May-2004 2:25pm est | http://www.trolocsis.com | #4503

foobar wrote:

The above posters are incorrect, as the syntax will direct cron to run your job in alternating periods of 90 and 30 minutes. Here's the correct syntax for cron (assuming your first job is scheduled to run at midnight):

0 0,3,6,9,12,15,18,21 * * * <commands>
30 1,4,7,10,13,16,19,22 * * * <commands>

∴ foobar | 13-Jul-2005 2:25am est | #7885

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

December 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 6 posts

Recent comments XML

new⇒Perl 6 1.0 in March?

Doh, my mistake. I'm aware of the​relation between Parrot and Rakudo​but I'...

Keith: Dec 2, 1:03am

Free image hosting sites

Well, TinyPic has this in its​FAQ:

> Images and videos is in​your accoun...

Keith: Dec 1, 1:13am

Join a NameValueCollection into a querystring in C#

Well with a lamba expression, this​is what I came up​with:

?!code:csharp...

Gustaf Lindqvist: Nov 30, 4:38pm

Why no generic OrderedDictionary?

Check​http://www.codeproject.com/KB/recip​es/GenericOrderedDictionary.aspx?d...

Gabrielk: Nov 27, 6:57am

WhatIsMyIP.com

http://www.thesysteminfo.com is​another good alternate to​whatismp.com... I...

Kripz: Nov 26, 8:51pm

Girls, please don't get breast implants

Actually I think it's sweet when a​man loves a woman whether she's big​or n...

218.186.12.228: Nov 26, 9:40am

Generated in about 0.18s.

(Used 8 db queries)

mobile phone