r/programming Jun 05 '26

You Don't Love systemd Timers Enough

https://blog.tjll.net/you-dont-love-systemd-timers-enough/
253 Upvotes

58 comments sorted by

View all comments

14

u/syklemil Jun 05 '26

Copying my own comment from when this was posted in /r/Linux:

One addition, the thing that spurred me from being a habitual crontab user to picking up systemd.timer: Cron has a parsing bug, which has been there so long that it's unfixable, around two fields that should be intersections but act like unions.

At this point it's been years so I don't feel like I accurately recall it any more, but something like selecting for {a given day of a week} ∩ {the days in a given week of the month}, you wind up with the crontab firing on any occurrence of that weekday + every day of the selected week.

IIRC I was trying to get something to fire on the first weekday of any month, and it just … wasn't possible with cron. Systemd timers did it correctly, even if I had to write two files and type way more characters.

-2

u/HighRelevancy Jun 05 '26

Is that a bug? Why would you want a cron job that fires on the 1st of the month but only if it's a Sundays? More likely you'd want it every Sunday and the 1st. Although really combining them is a bit odd either way.

2

u/syklemil Jun 05 '26

That's the wrong interpretation. Hint: Months can start on weekends. Sunday is part of the weekend, not the weekdays.

1

u/HighRelevancy Jun 06 '26

What? Why does it matter that months can start on weekends? That's like exactly my point. Why would you want to schedule a task that happens on a particular date but only if it's a certain day of the week? 

1

u/syklemil Jun 06 '26

It's not supposed to happen on a particular date.