Is the following cron expression means every 45 minutes? [duplicate]

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.


Solution 1:

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 * * *

Solution 2:

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.

Solution 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.