[TriLUG] Why does my "every second month" cron job run on odd-numbered months?

Brian via TriLUG trilug at trilug.org
Thu Aug 28 14:12:52 EDT 2025


On 8/28/25 13:07, Aaron Joyner via TriLUG wrote:
> Paul's right.  Assuming you're using vixie cron (or a derivative, or most
> any implementation?), the cron field for month is one-ordered, and so
> unpacking the wildcard in your step command works morally like this:
> 0 3 1 *1,2,3,4,5,6,7,8,9,10,11,12*/2 * /do/a/thing.sh
> 
> Walking that schedule takes every other step, starting with the 1.  

Always glad to hear you chime in, Aaron!  I hope you're thriving.

And I guess this is where my mental logic doesn't match up with cron 
logic.

Given [a, b, c, d, e, f, g, h],

"every second item" to me distinctly means [b, d, f, h] and most 
certainly not [a, c, e, g].  "First" (in the original list) is not in 
the set "every second" because "first" is not a "second".  "Second" is 
"second", so "every second" should start with the first "second" 
(confusing enough?).

Anyway, no amount of me defending my logic will change what cron 
actually does, so thank you to both Paul and Aaron for the responses!

Cheers,
-B



More information about the TriLUG mailing list