Why does crontab use OR when both the day of the month and the day of the week are specified?

This is a known issue: when the crontab line contains both the day of the week and the day of the month, cron uses OR to calculate the day to run the command. For example. if you write

* * 13 * 5 command

the team will be executed every Friday and every 13th day of the month, and not only on Fridays, which occupy 13th place. This contradicts the format for other fields (when you write 30 2 * * *, it will be executed only when both hours and minutes - exactly what you specified is the same for all other fields except DoW and DoM when they are both specified )

So my question is: is there a specific reason for this exception? I mean, there must be a reason, but I cannot find it. (And instead, I see a lot of people on the Internet who would like these fields to be handled by both others and the I-strategy for things like Friday the 13th or the second Thursday of May. .)

+4
source share
1 answer

I work on a Unix server that uses a lot of scripts in crontab. It is very convenient for us to indicate specific dates in scripts that should run on the same day of the week. In my case, I do not understand why I will run the scheduled script on the day of the week ONLY if it is on the 13th, taking your example.

+2

Source: https://habr.com/ru/post/1620756/


All Articles