1.11M Members

Cron job interval larger than 60 mins

 
0
 

I'm not sure exactly which forum to ask this,so I'm starting here,

I have a cron job I want to execute every 72 minutes. I've researched how to schedule the job for an interval of 60 min or less, but is there a way to specify a minutes interval when the required interval is > 60 ?

 
2
 

I think you can use a multi-entry crontab like this:

0 0,5,10,15,20 * * * cmd-to-run
12 1,6,11,16,21 * * * cmd-to-run
24 2,7,12,17,22 * * * cmd-to-run
36 3,8,13,18,23 * * * cmd-to-run
48 4,9,14,19 * * * cmd-to-run

 
0
 

How would i use that to define an interval of every 72 minutes ? Not sure I understand.

 
1
 

Rubberman has you running the command
on the hour for 12 midnight, 5 am, 10 am, etc.
12 mins after the hour for 1 am, 6 am, ...
24 mins after the hour for 2 am, 7 am, ...
etc.
Very clever.

 
0
 

Rubberman,

I appreciate this post, as it cemented cron methodology in my own mind, something I had previously not fully understood (having never actually used cron before). That being said, in evaluating the lines you provided, I believe I may see a minor problem.

Original post:

0 0,5,10,15,20 * * * cmd-to-run
12 1,6,11,16,21 * * * cmd-to-run
24 2,7,12,17,22 * * * cmd-to-run
36 3,8,13,18,23 * * * cmd-to-run
48 4,9,14,19 * * * cmd-to-run

If I understand this correctly, those lines, as written, will fire at 00:00, 01:12, 02:24, 03:36, 04:48, and then cycle to 05:00, which would be 12 minutes after the 04:48 occurrence rather than 72. Would the following adjustment fix it? Again, this is a newbie trying to understand, so please forgive my any appearance of presumption:

0 0,6,12,18 * * * cmd-to-run
12 1,7,13,19 * * * cmd-to-run
24 2,8,14,20 * * * cmd-to-run
36 3,9,15,21 * * * cmd-to-run
48 4,10,16,22 * * * cmd-to-run

I believe this will make the last occurrence be 22:48, leaving 72 minutes until 00:00, at which point the cron job would then start over again exactly right. Starting at midnight every night, this should run the command every 72 minutes around the clock, assuming one has put the same command in place of cmd-to-run on each line.

 
0
 

hi,

 for ((n=0; n<24*60;n+=72)); do date -d "00:00 $n min" +%H\ %M; done |\
     awk 'BEGIN{PROCINFO["sorted_in"]="@ind_num_asc"}
          {$1=$1?$1:"00";a[$2]=a[$2]?a[$2]","$1:$1}
          END{for(i in a)printf("%d\t%s\t* * *\tcmd-to-run\n", i, a[i])}'
0       00,06,12,18     * * *   cmd-to-run
12      01,07,13,19     * * *   cmd-to-run
24      02,08,14,20     * * *   cmd-to-run
36      03,09,15,21     * * *   cmd-to-run
48      04,10,16,22     * * *   cmd-to-run
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: