I need to run oneshot bash script once a day (log rotation and cleaning). I saw some examples stated to use:
OnCalendar=daily
Persistent=true
and another examples using:
OnBootSec=20min
OnUnitActiveSec=1d
What is more optimal for anacron-a-like behaviour?
Best Answer
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.