Comment by networked
44 minutes ago
Complex expressions are one of the things I don't like in cron. On Debian/Ubuntu servers, I bite the bullet with systemd timers. On my workstation, I have a personal job scheduler that feels easier and more fun to tinker with. The scheduler uses Starlark functions instead. For example:
# Run if at least a day has passed since the last run
# and it isn't the weekend.
def should_run(finished, timestamp, dow, **_):
return dow not in [0, 6] and timestamp - finished >= one_day
This was inspired by GNU mcron. In mcron, jobs can calculate the next time they should run using Guile (https://www.gnu.org/software/mcron/manual/mcron.html#Guile-S...):
(job
'(next-minute-from
(next-hour (range 0 24 2))
'(15))
"my-program")
I found mcron's scheduling counterintuitive and decided I wanted a function that returned a boolean. I can recommend this approach so far.
No comments yet
Contribute on Hacker News ↗