tags:

views:

2832

answers:

5

How can I set cron to run certain commands every one and a half hours?

+1  A: 

Is there a good reason why you can't use 1 hour or 2 hours? It would be simpler for sure.

I haven't tried this personally, but you can find some info here on getting cron to run every 90 minutes: http://keithdevens.com/weblog/archive/2004/May/05/cron

An excert from the above link:

0 0,3,6,9,12,15,18,21 * * * <commands>
30 1,4,7,10,13,16,19,22 * * * <commands>
vfilby
down-voted because it ignores the requirement
Alnitak
Which requirement? First sentence questions the necessity of 1.5 hours, the second provides a blog post with information on how to do it every 1.5 hours.
vfilby
Upvoted because the blog post answers the question correctly.
Paul Tomblin
It didn't clearly reference that when I down-voted it. It has been edited since to make it clear that the link is to a potential solution for the 90 minute question.
Alnitak
Aye, I clarified the post.
vfilby
+13  A: 

That's not possible with a single expression in normal cron.

The best you could do without modifying the code is:

0 0,3,6,9,12,15,18,21 * * * [cmd]

30 1,4,7,10,13,16,19,22 * * * [cmd]

These might be compressible, depending on the version of cron you have to:

0 */3 * * * [cmd]

30 1-23/3 * * * [cmd]

Alnitak
+1  A: 

Two lines in the crontab. Along the lines of:

0 0,3,6,9,12,15,18,21 * * * /usr/bin/foo
30 1,4,7,10,13,16,19,22 * * * /usr/bin/foo
ConcernedOfTunbridgeWells
+1  A: 

You could do it with two crontab entries. Each runs every three hours and they are offset by 90 minutes something like this:

0 0,3,6,9,12,15,18,21 * * *

30 1,4,7,10,13,16,19,22 * * *

Thomas DeGan
A: 

You could also use fcron which also accepts more complex time specifications such as :

@ 01h30 my_cmd
Christian Lescuyer