4 ms·
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 su
by albertgoeswoof 4y ago
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
- jagged-chisel 4y agoIf 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.
- jcelerier 4y agoWith 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 4y agohttps://manpages.debian.org/bullseye/systemd/systemd.time.7.en.html https://manpages.debian.org/bullseye/systemd/systemd.time.7....
- pram 4y agoBig time upvote for informing me systemd has timers.
- Karellen 4y agosystemd can also manage running your cron scripts itself, with `systemd-cron` https://github.com/systemd-cron/systemd-cron https://github.com/systemd-cron/systemd-cron
- eth0up 4y agoSystemd 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.
- baggy_trough 4y agosystemd timers have a good chance to do what you want the first time, unlike cron.
- minusf 4y ago> With systemd if I'm not mistaken this is just: 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?
- yrro 4y agoHere'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 Credit: https://www.redpill-linpro.com/sysadvent/2016/12/07/systemd-timers.html https://www.redpill-linpro.com/sysadvent/2016/12/07/systemd-...