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

John Abreau jabr at blu.org
Tue Oct 18 23:29:03 EDT 2011


My experience is exactly the opposite. I've never run into a situation
you describe, but it would be trivially easy to specify it with two
cron entries: one specifying Mondays, and the other specifying
the first of the month.

On the other hand, my "odd case" that you claim is not particularly
useful is one that I see all the time. Pretty much every program I've
ever seen for scheduling events includes this, cron being the
most notable exception. For the few others that lacked it, I recall
reading reviews in magazines like PC World giving them bad marks
for leaving out the feature. This leads me to believe that I'm not the
only person on the planet who finds this functionality particularly useful.

If you want other examples other than my user group, my local
chapter of Toastmasters meets on the first and third Tuesdays
of every month. At my previous job, we had a monthly staff meeting
on the fourth Friday of every month. Back when the Boston Computer
Society still existed, pretty much every BCS SIG would meet once a
month on the n'th $WEEKDAY of the month. Doesn't GNHLUG
also schedule its meetings in this manner?

In any case, my question was about the original author's reasoning.
I've poked around a bit more and learned that Brian Kernighan
was the original author, but I still haven't found anything where
he explains why he chose that behavior.

Did you read somewhere that your use case was actually what
Brian had in mind? If so, can you share a link to the article
or point me to the book or magazine issue that you read it in?



On Tue, Oct 18, 2011 at 10:45 PM, Ken D'Ambrosio <ken at jots.org> wrote:
> 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/
>
>
>
>
>
>



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



More information about the Discuss mailing list