|
|
|
|
|
by TylerE
1411 days ago
|
|
My favorite cron “feature” is that the day of week field operates acts as an “or” and not an “and”. This will come as an unpleasant surprise when you try to schedule something to run on, say, the first Friday of the month. There are workarounds, mostly involving backticked date invocations, but they’re hard to both write and read. |
|
0 0 */50,1-7 * FRI
It works, but it's a bit of a hack (to put it mildly ;-) )
Consider this expression:
0 0 1-7 * FRI
This one will run on dates 1-7, and additionally on every Friday. This is almost what we want, except we want an "AND" relationship between the day-of-month and the day-of-week fields, instead of the "OR" relationship.
The weird extra */50 bit exploits a quirk in Debian cron's expression parsing logic. It fools cron into thinking the day-of-month field is a wildcard field, and into applying the "AND" logic.