4

Possible Duplicate:
How does cron handle remainders in “every so often” jobs

Am willing to run a script every 45 minute (not the :45th minute of every hour)

e.g. 10:00, 10:45, 11:30, 12:15, and so on.

*/45 * * * *

Am not sure this is the correct expression.

0

3 Answers 3

9

No, this means that you will run a command on minutes that are evenly divisible by 45. I.e., 12:45, 1:45, 2:45, etc.. If you want to run the command every 45 minutes, you have two options. First, you should have your script have some knowledge of when it's running and just have cron run */15 minutes and check to see if it's a 45 minute interval from what it expects. The second option is a lot more annoying to configure:

0,45 0,3,6,9,12,15,18,21  * * *
30   1,4,7,10,13,16,19,22 * * *
15   2,5,8,11,14,17,20,23 * * *
1
  • The following script can do the job. * * * * * (( $(echo $(date '+(%M+%H*60)')%45 | bc) )) || your job Nov 9, 2022 at 15:19
3

No, this will only run the script once at 45 minutes past each hour as the interval is reset (in this case) every 60 minutes. You could use something like

*/15 * * * * ...

and have your script figure out if it should run or not.

3

Check wiki.

My understanding is that this will be every 45th minute of the hour. (e.g. 10:45).

So */15 would run at 10:00, 10:15, 10:30, 10:45, but */45 will run at 10:00 and 10:45.

Important difference: */n = nth minute not every n minutes.

3
  • A very important concept here is to note that */15 will run at 10:00, 10:15, 10:30, 10:45, etc..
    – Andrew M.
    Jan 25, 2013 at 8:23
  • Well spotted, will edit my answer.
    – LuckySpoon
    Jan 25, 2013 at 9:21
  • 1
    Which presumably also means that */45 will run at 10:00 and 10:45.
    – MadHatter
    Jan 25, 2013 at 10:43

Not the answer you're looking for? Browse other questions tagged .