Re:A quick and simple editor for cron schedule expressions
by MawKKe on Monday August 30, 2021 @04:25PM
(#28360488)
Related note: with systemd you are probably better off using its OnCalendar facilities. There is even a tool called 'systemd-analyze', which can be used for verifying the correctness of your OnCalendar timespec:
[ Parent
| on HN ]
Re:A quick and simple editor for cron schedule expressions
by linsomniac on Monday August 30, 2021 @08:09PM
(#28362487)
That's a really interesting idea that wasn't on my radar. We make extensive use of cron, including fairly complicated job wrappers to do things like provide status to our monitoring system and prevent running the same job multiple times in parallel. I like to break these out into actual shell scripts if it gets too complicated, but some of these things might be simplified through using systemd units and timers. Plus we could gain some additional functionality, like chaining jobs, which we currently do with "This job shouldn't run more than X minutes, so schedule the follow on job +X minutes from the last one". Plus, do I understand you can schedule jobs on the second?!? :-)
Re:A quick and simple editor for cron schedule expressions
by x0 on Monday August 30, 2021 @09:55PM
(#28363145)
Like many things in systemd, timers are a bit complex, I always find myself opening 2-3 manpages at once when doing one. But when you get them set up, it's just a much better system. I still use cron for basic one-liners, but that's it.
Re:A quick and simple editor for cron schedule expressions
by aprdm on Monday August 30, 2021 @11:31PM
(#28363670)
Systems timers do not allow jobs to overlap which is a nice feature vs wrapping a cron on flock
Re:A quick and simple editor for cron schedule expressions
by pabs3 on Tuesday August 31, 2021 @01:58AM
(#28364419)
The randomisation features of systemd timers are pretty essential, to avoid lots of systems running the same thing at the same time. To do that in cron you have to do ugly things like use bash and then run sleep $RANDOM.
Re:A quick and simple editor for cron schedule expressions
by xorcist on Tuesday August 31, 2021 @03:34AM
(#28364929)
Several cron implementations (including the default in Red Hat-derived distributions) have a built-in RANDOM_DELAY variable you can set.
I prefer setting the random offset when writing/deploying the crontab (you probably have them committed somewhere so there's bound to be a deployment mechanism, such as ansible). This way the offset is kept constant, while still avoiding the "thundering" cron.