Hacker News new | ask | show | jobs
by hashworks 861 days ago
While I support systemd timers over cron, AFAIK cron has stuff like @hourly.
3 comments

Some cron implementations do, it's not portable.
Neither are systemd timers. I don't think there's a single system out there implementing the systemd timer interface.
What do you mean? There's a single implementation as far as I know, deployed on many distributions and working identically.
> There's a single implementation as far as I know

That's exactly what I mean.

Systemd itself, including timers, is deeply coupled with the Linux API, and cannot be (easily) ported on any other system. Cron, on the other hand, exists on almost every UNIX-like system.

I'm sure the few people who run BSD systems will be fine with cron's arcane syntax.
systemd is is many things, but obvious and accessible is not one of them. It has a lot of power and flexibility, but the trade off is a lot of complexity. Just look at the unit configuration file:

https://www.freedesktop.org/software/systemd/man/latest/syst...

I've never heard of a systemd timer before, but I guessed it was a type of unit file, so I just read the documentation:

https://www.freedesktop.org/software/systemd/man/latest/syst...

I have no idea from that documentation how I'd run something every hour. I guess I have to create a new unit file, and use the OnCalendar stanza? But what do I set it to? I'm directed to this page:

https://www.freedesktop.org/software/systemd/man/latest/syst...

Oh, I see I can use "hourly" but it turns out that's syntactic sugar for:

  *-*-* *:00:00
Is that really any easier than the cron equivalent?

  0 * * * *
Which can also be written (on FreeBSD) as:

  @hourly
https://man.freebsd.org/cgi/man.cgi?query=crontab&sektion=5&...

I started my career as a Unix SA over 25 years ago and have worked with a lot of different Unix-flavored operating systems: SunOS/Solaris, HP/UX, FreeBSD, Linux (Slackware, RedHat, Debian), macOS/OS X, AIX. I'm familiar with all their different variations of init.

All of them are esoteric in one way or another. Some of them have their behavior right out in the open where it's easy to see (inittab and rc scripts). Others hide away massive complexity (launchd and systemd) and require extensive documentation to understand.

I appreciate all the power that systemd provides. It gets a lot of things right. But in terms of complexity, it's almost an operating system unto itself.

Portable has a well-defined meaning.

You can argue that no other system matters (which I strongly disagree with for reasons I don't want to get into right now), but that doesn't make systemd timers any more portable.

systemd also has shorthands like "hourly": https://www.man7.org/linux/man-pages/man7/systemd.time.7.htm...

The man page lists: minutely, hourly, daily, monthly, weekly, yearly, quarterly, semiannually (and "annually" further down in examples).

It doesn't have a "hourly" directory where you can drop in scripts though, AFAIK.

And SLURM's scrontab has @fika, @teatime, and - as of yesterday - @elevenses.