I think this just speaks to a design wart in the seemingly simple crontab specification. I'm personally more of a fan of iCal-style (RFC5545) recurrence specification. Just check out the examples in https://www.rfc-editor.org/rfc/rfc5545#section-3.8.5.3
Here are some thing that's possible:
Weekly on Tuesday and Thursday for five weeks
Every other week on Monday, Wednesday, and Friday until December 24, 1997, starting on Monday, September 1, 1997
Every other month on the first and last Sunday of the month for 10 occurrences
Every 18 months on the 10th thru 15th of the month
(Almost all of those are well supported by the UI on Apple Calendar and Google Calendar.)
I only wish it could incorporate astronomical phenomena such as phases of the moon into account. Wouldn't it be great if it can express concepts like "the first Sunday after the full moon that occurs on or after the spring equinox" (no I'm not making this example up)?
There is a trend towards turing-complete configuration languages, so why not. Of course there might be a race condition if the computation takes longer than the remaining time to the computed date.
At that point you might as well put a code interpreter in your scheduler that just gets current date and returns next data of event, because whole code to cover that would take more code than cron itself.
It reads like the “if” clause only pertains to the second “every”, but it also applies to the first. In this instance it doesn’t make a real difference, but presumably the Englishfier doesn’t know that.
Instead of tricking the syntax, I just check in the command. I have a cron entry set up to run every Monday, but I limit it to the start of the month with:
[ $(date +\%d) -le 07 ] && <actual command>
i'm not familiar with the systemd syntax but according to the desc you provided, wouldnt that be a weekly monday job, not "first monday of the month" the article wanted?
Here's "first monday of every month" in systemd.time(7) format:
$ systemd-analyze calendar 'Mon *-*-1..7 10:00'
Original form: Mon *-*-1..7 10:00
Normalized form: Mon *-*-01..07 10:00:00
Next elapse: Mon 2022-10-03 10:00:00 BST
(in UTC): Mon 2022-10-03 09:00:00 UTC
From now: 1 week 1 day left
Systemd whitens teeth, strengthens bridges and stabilizes the cosmos. It's also good on sandwiches and has limitless applications for everything. It's the most viable explanation for gravity by far. It deserves our prayers. It permeates the aether. Nothing prevents it from ruling the universe.
an excellent example of how not to do things. if you need something esoteric enough that no one is going to grok the crontab without thought then you use something else.
I know, with eventbridge and lambdas this problem could be alleviated a bit, since eventbridge uses cron syntax but with some added bells and whistles ( https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-...) which would make the expression for the first monday of each month much easier to write.
Here are some thing that's possible:
(Almost all of those are well supported by the UI on Apple Calendar and Google Calendar.)I only wish it could incorporate astronomical phenomena such as phases of the moon into account. Wouldn't it be great if it can express concepts like "the first Sunday after the full moon that occurs on or after the spring equinox" (no I'm not making this example up)?