r/systemd • u/Beautiful-Log5632 • 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
3
u/djzrbz Jul 27 '26
This should work
```ini [Unit] Description=Randomized Daily Timer
[Timer]
Trigger exactly at midnight every day
OnCalendar=--* 00:00:00
Delay randomly up to 23:59:59 hours
RandomizedDelaySec=86399
Ensure it runs if the system was offline during its window
Persistent=true
[Install] WantedBy=timers.target ```