I need to run oneshot bash script once a day (log rotation and cleaning). I saw some examples stated to use:OnCalendar=dailyPersistent=trueand another examples using:OnBootSec=20minOnUnitActiveSec=1dWhat is more optimal for anacron-a-like behaviour?
systemd timer OnUnitActiveSec vs OnCalendar for anacron replacement
systemd
For anacron-like behavior, you'll want to use the former, where you specify a certain time and have it track when the task was last run (and to run it if it missed a run). The latter says to run the task 20 minutes after the system was booted, and then every 24 hours thereafter.However, in my opinion, you should determine which one to use on a task-by-task basis, whether the task needs to run daily (at a specific time), or if it needs to run relative to some system event.