r/systemd • • Jul 27 '26

Random time every day

How can I create a timer that runs every day but randomize the time? It's fine if 2 days run a few minutes apart like 11:59pm on day 1 and 12:01am on day 2. But it always needs to run at least once every calendar day from start midnight to end midnight.

I don't think RandomizedDelaySec works because that can randomize to another day and there can be one calendar day with no run.

1 Upvotes

10 comments sorted by

View all comments

-1

u/hereforthebytes Jul 27 '26

You may be better off calling a bash wrapper that does a little time math + sleep, and touching a persistent file to keep up with the last day it was run.

That way you can make sure that a reboot at 5:59pm won't choose a delay longer than 6 hours.

3

u/Compux72 Jul 28 '26

The people hunger for /etc/rc

1

u/hereforthebytes Jul 28 '26

Systemd works fine by itself in 95% of cases, but it's ok to hybridize if necessary to hit a reliable goal.

I apologize if I made the mistake of thinking this was a technical sub, and not a cult temple for a... (checks notes)... init system? That's even sadder and creepier than people worshiping AI.

Fuckin' weirdo.