<a href="https://htmx.org/essays/locality-of-behaviour/" rel="nofollow">https://htmx.org/essays/locality-of-behaviour/</a><p>Locality of behavior is important. Note how this systemd-thingy is split into two separate files? It's like that a lot in systemd, whoever is doing the architecture doesn't seem to understand why locality of behavior would be desirable, instead taking the IDE approach of writing a bunch of tools to make managing the increased complexity more manageable. Don't glance at a crontab to see when things will next execute, run some other tool that will inspect everything for you. Make things more complex and difficult to read, and then write tools to make it easier to read again.<p>They could have just added "periodic" service type that accepts timer options, and at least then it wouldn't have to be two files.<p>Most of the advantages really don't seem like advantages to me. Templated unit files seems especially silly since it's equivalent to just copy and pasting a line in your crontab and changing an argument.<p>Seems to work for a lot of people, it's just not to my tastes I guess. Still, I find the whole thing pretty mystifying.
While I agree Systemd timers aren't as ergonomic to set up - there are some benefits that I would basically never give up at this point.<p>* Running the service on command ( this is the best way to troubleshoot issues with your slightly different environments / cron's version of shell. I've spent many minutes over my career - setting the crontab one minute and the future and waiting for it to run / fail )<p>* Easily inspecting when the next run of the service is. ( list-timers )<p>* Straightforward access to the logs ( Always journalctl )<p>* Specifying environment variables easily<p>* OnFailure
You can pry my crontab out of my cold, dead hands.<p>Seriously, though, cron has been so utterly reliable for me for so many decades now, it will be really hard for me to ever give it up.
I've had the opportunity to delve into systemd in a previous role.<p>This sounds a bit weird, but its not easy to get started with, <i>unless</i> you're used to reading man pages. But once you're able to read man pages, all of systemd behavior is documented in the man pages. I do wish there were more human friendly docs though, especially for younger engineers used to better sorts of docs.<p>Anyways, once you do get the hang of it, its an immensely powerful system, but like any such system it has its quirks and edge cases. You can get 99% of what you need with it though, and for low level tasks on machines, its pretty amazing.
Some time ago I wanted the best bits from both worlds:<p>- from cron: specifying all jobs in one file instead of scattering it across dosens of unit files. In 90%
of cases I just want a regular schedule and the command, that's it<p>- from systemd: mainly monitoring and logging. But also flexible timers, timeouts, resource management, dependencies -- for the remaining 10% of jobs which are a little more complicated<p>So I implemented a DSL which basically translates a python spec into systemd units -- that way I don't have to remember systemd syntax and manually manage the unit files. At the same time I benefit from the simplicity of having everything in one place.<p>An extra bonus is that the 'spec' is just normal python code<p>- you can define variables/functions/loops to avoid copy pasting<p>- you can use mypy to lint it before applying the changes<p>- I have multiple computers that share some jobs, so I simply have a 'common.py' file which I import from `computer1.py` and `computer2.py` -- the whole thing is very flexible.<p>You can read more about it here:<p>- <a href="https://beepb00p.xyz/scheduler.html" rel="nofollow">https://beepb00p.xyz/scheduler.html</a><p>- <a href="https://github.com/karlicoss/dron#what-does-it-do" rel="nofollow">https://github.com/karlicoss/dron#what-does-it-do</a><p>I've been using this tool for several year now, with hundreds of different jobs across 3 computers, and it's been working perfectly for me. One of the best quality of life improvements I've done for my personal infrastructure.
The one time I've tried to use this in anger, it said my script was running when it was supposed to and exiting cleanly, everything green, but <i>nothing</i> was happening.<p>Put it in cron, worked first try, and forgot about it.
When I set up a new box, the first thing I do is disable all sorts of systemd-* nonsense, keeping systemd as an initd service only (which it should be). Then I replace them with serious, battle-tested tools like ntp/chrony, unbound, etc...<p>It looks like systemd.timer will continue this practice ;) I'm expecting someone at Canonical/IBM/RH will be happy to put this as the default scheduler in the next distro release, marking it as a "significant improvement".
I don't get the first argument. Put the whole command in a shell script and be done with it. You can easily run it anytime you want to.<p>Same with the last - templated unit files. Add a parameter or more to the script and you're done.
> Job output will automatically be written to systemd-journald<p>This is a bad thing, not something I’d boast about.<p>I actually really enjoy using systemd. Being able to start a process with complete isolation without heavyweight docker downloading mystery meat off the internet is a huge boon.<p>However, one thing systemd is logging. Jounalctl sucks. Grep, cat, etc, work infinitesimally better.