How to specify the time for automated system updates (dnf-automatic)?

\AutoUpdates - Fedora Project Wiki
\DNF Automatic — dnf latest documentation

I take frequent backups with borg and decided to automate updates. The documentation was otherwise easy to follow, but I haven’t entirely understood how to configure the process to start at a specified time.

the /usr/lib/systemd/system/dnf-automatic-install.timer file contents:

[Unit]
Description=dnf-automatic-install timer
# See comment in dnf-makecache.service
ConditionPathExists=!/run/ostree-booted
Wants=network-online.target

[Timer]
OnCalendar=*-*-* 6:00
RandomizedDelaySec=60m
Persistent=true

[Install]
WantedBy=timers.target

According to the comments on this Reddit post, OnCalendar=*-*-* means “every day” (and 6:00 time of the day, as evident). How would one modify the line to update bi-daily (every other day) and once a week, for instance?

2 Likes

There are multiple ways to do that, systemd timers are very flexible, for example those will run one week or two days after last execution, no sooner than 15 minutes after boot (if computer is off, it will be run after next boot up):

[Timer]
OnBootSec=15min
OnUnitActiveSec=1w

or

[Timer]
OnBootSec=15min
OnUnitActiveSec=2d 

If your computer is constantly on, it’s best to schedule a backup for night with OnCalendar and weekly (which works as Mon *-*-* 00:00:00) or any other day and hour Tue,Fri,Sun *-*-* 01:00:00.

[Timer]
OnCalendar=weekly
Persistent=true

Here are some useful examples: systemd/Timers - ArchWiki
All available options are documented here:
systemd.timer
systemd.time

7 Likes