Historical origin of cron's day-of-month/weekday behavior?

Ken D'Ambrosio ken at jots.org
Tue Oct 18 22:45:26 EDT 2011


Not trying to sound snooty, but this seems so obvious to me that I almost
wonder if I'm missing the point.  All the other fields deal with different
units -- minutes, hours, months.  day-of-month and weekday both apply to days;
so, if you wanted something to execute on both Mondays *and* the first day of
the month (say, a process that ensured that a given week/month was started
afresh), then you'd use both of the fields.  The opposite case, where things
are ANDed -- the intersection of the day of the month with the day of the week
-- is an odd enough set that I don't see it being particularly useful.

Have I, perhaps, misunderstood something?

$.02, YMMV, etc.,

-Ken


On Tue, 18 Oct 2011 22:25:31 -0400 John Abreau <jabr at blu.org> wrote

> One thing that's always annoyed me about cron is how it handles the
> weekday field differently from the other fields. The first four fields,
> minute, hour, day-of-month, and month, are logically ANDed, but
> the day-of-month and weekday fields are ORed.
> 
> The man page describes the behavior, but does not explain the
> reasoning behind it:
> 
> >     Note: The day of a command's execution can be specified by two fields
> >     -- day of month, and day of week.  If both fields are restricted (ie,
> >     are not *), the command will be run when either field matches the
> >     current time.  For example, ''30 4 1,15 * 5'' would cause a command to
> >     be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
> 
> I've looked for an explanation for this in the past, but I've never
> had any luck finding one. Making this a special case makes the code
> needlessly more complicated and fragile, and it sacrifices useful
> functionality; if the weekday had been ANDed like the other fields,
> it would be trivially easy to specify things like "third Wednesday
> of the month".
> 
>  I'm unable to find or think of a use case that would make the special
> behavior useful, and I have to wonder why it was designed this way.
> 
> Can anyone point me to the original author's thoughts on this?
> 
> 
> 
> -- 
> John Abreau / Executive Director, Boston Linux & Unix
> Email jabr at blu.org / WWW http://www.abreau.net / PGP-Key-ID 0xD5C7B5D9
> PGP-Key-Fingerprint 72 FB 39 4F 3C 3B D6 5B E0 C8 5A 6E F1 2C BE 99
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/







More information about the gnhlug-discuss mailing list