[HN Gopher] Schedule Cronjob for the First Monday of Every Month...
___________________________________________________________________
Schedule Cronjob for the First Monday of Every Month, the Funky Way
Author : todsacerdoti
Score : 64 points
Date : 2022-09-23 08:27 UTC (1 days ago)
(HTM) web link (blog.healthchecks.io)
(TXT) w3m dump (blog.healthchecks.io)
| wkdneidbwf wrote:
| 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.
| drekipus wrote:
| Unfortunately the crontab englishfier doesn't do a great job of
| describing it,
|
| https://crontab.guru/#0_0_*/100,1-7_*_MON
|
| This is a nice hack, but readability has gone out the window and
| it's really just much safer to fail early in the job itself.
| cdubzzz wrote:
| > At 00:00 on every 100th day-of-month and every day-of-month
| from 1 through 7 if it's on Monday.
|
| I guess I'm confused. Isn't that exactly correct?
| ldjb wrote:
| It is correct, but a lot wordier than "At midnight on the
| first Monday of every month."
| [deleted]
| albertgoeswoof wrote:
| Given the odd quirks and number of cron "translation" sites, it
| strikes me that the cron syntax might not be the best approach to
| scheduling tasks.
|
| There is surely a better DSL for this.
|
| Personally I like ruby's whenever gem, that transpiles to cron,
| where you can do things like every :sunday, at:
| '12pm' do foo end
|
| But I guess we are just stuck with crontab
| jcelerier wrote:
| With systemd if I'm not mistaken this is just:
| OnCalendar=Mon *-*-* 12:00:00
|
| Here's the list of examples from man systemd.time:
| The following special expressions may be used as shorthands for
| longer normalized forms: minutely -
| *-*-* *:*:00 hourly - *-*-* *:00:00
| daily - *-*-* 00:00:00 monthly - *-*-01
| 00:00:00 weekly - Mon *-*-* 00:00:00
| yearly - *-01-01 00:00:00 quarterly -
| *-01,04,07,10-01 00:00:00 semiannually -
| *-01,07-01 00:00:00 Examples for valid
| timestamps and their normalized form:
| Sat,Thu,Mon..Wed,Sat..Sun - Mon..Thu,Sat,Sun *-*-* 00:00:00
| Mon,Sun 12-*-* 2,1:23 - Mon,Sun 2012-*-* 01,02:23:00
| Wed *-1 - Wed *-*-01 00:00:00
| Wed..Wed,Wed *-1 - Wed *-*-01 00:00:00
| Wed, 17:48 - Wed *-*-* 17:48:00 Wed..Sat,Tue
| 12-10-15 1:2:3 - Tue..Sat 2012-10-15 01:02:03
| *-*-7 0:0:0 - *-*-07 00:00:00
| 10-15 - *-10-15 00:00:00 monday *-12-*
| 17:00 - Mon *-12-* 17:00:00 Mon,Fri *-*-3,1,2
| *:30:45 - Mon,Fri *-*-01,02,03 *:30:45
| 12,14,13,12:20,10,30 - *-*-* 12,13,14:10,20,30:00
| 12..14:10,20,30 - *-*-* 12..14:10,20,30:00
| mon,fri *-1/2-1,3 *:30:45 - Mon,Fri *-01/2-01,03 *:30:45
| 03-05 08:05:40 - *-03-05 08:05:40
| 08:05:40 - *-*-* 08:05:40
| 05:40 - *-*-* 05:40:00 Sat,Sun 12-05
| 08:05:40 - Sat,Sun *-12-05 08:05:40
| Sat,Sun 08:05:40 - Sat,Sun *-*-* 08:05:40
| 2003-03-05 05:40 - 2003-03-05 05:40:00
| 05:40:23.4200004/3.1700005 - *-*-* 05:40:23.420000/3.170001
| 2003-02..04-05 - 2003-02..04-05 00:00:00
| 2003-03-05 05:40 UTC - 2003-03-05 05:40:00 UTC
| 2003-03-05 - 2003-03-05 00:00:00
| 03-05 - *-03-05 00:00:00
| hourly - *-*-* *:00:00
| daily - *-*-* 00:00:00 daily
| UTC - *-*-* 00:00:00 UTC
| monthly - *-*-01 00:00:00
| weekly - Mon *-*-* 00:00:00 weekly
| Pacific/Auckland - Mon *-*-* 00:00:00 Pacific/Auckland
| yearly - *-01-01 00:00:00
| annually - *-01-01 00:00:00
| *:2/3 - *-*-* *:02/3:00
| Karellen wrote:
| https://manpages.debian.org/bullseye/systemd/systemd.time.7..
| ..
| jagged-chisel wrote:
| If you can write the DSL and a reference parser, you might have
| a chance at adoption. Even better if you can convert from and
| to crontab.
| kccqzy wrote:
| 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)?
| dogline wrote:
| I guess you can just say "Easter 2023"
| kccqzy wrote:
| The idea is not to hard code the computation of specific
| holidays, but to make the specification flexible enough.
| macintux wrote:
| Orthodox or Catholic?
| gsich wrote:
| gauss doesn't care, the changes are minimal.
___________________________________________________________________
(page generated 2022-09-24 23:00 UTC)