I’m seeking a little help with automatic updates on a Fedora IoT server. I realize that by enabling rpm-ostreed-automatic.timer, it will trigger the service as specified in /etc/rpm-ostreed.conf. If that config contains “AutomaticUpdatePolicy=apply”, the automatic updates are downloaded, applied, and the system rebooted. This I can do successfully; however the problem I am struggling with is changing the timing of auto-updates. My goal was to have the command run once a week on Tuesday at 5AM CST.
With the below changes, the automatic update fires off on Tuesday, but then it activates everyday as well. Cockpit show the next trigger will be in a week, however the log show the service is activating daily and rebooting the system. What did I do wrong? Any help would be appreciated. I have done the following:
sudo systemctl edit rpm-ostreed-automatic.timer
Then added the following:
### Editing /etc/systemd/system/rpm-ostreed-automatic.timer.d/override.conf
### Anything between here and the comment below will become the contents of the drop-in file
[Unit]
Description=rpm-ostree Automatic Update Trigger
Documentation=man:rpm-ostree(1) man:rpm-ostreed.conf(5)
ConditionPathExists=/run/ostree-booted
[Timer]
OnCalendar=Tue *-*-* 5:00:00
Persistent=true
[Install]
WantedBy=timers.target
### Edits below this comment will be discarded
### /usr/lib/systemd/system/rpm-ostreed-automatic.timer
# [Unit]
# Description=rpm-ostree Automatic Update Trigger
# Documentation=man:rpm-ostree(1) man:rpm-ostreed.conf(5)
# ConditionPathExists=/run/ostree-booted
#
# [Timer]
# OnBootSec=1h
# OnUnitInactiveSec=1d
#
# [Install]
# WantedBy=timers.target
Then ran:
sudo systemctl daemon-reload
Afterward I enabled the timer via Cockpit, and then rebooted the system. The timer triggered the following Tuesday and then everyday there after. It feels like my systemd timer override is running alongside the original timer’s configuration.
When trying to override the defaults of a systemd unit/timer, you have to clear out existing settings you no longer want to be set. See: systemd.unit
Note that for drop-in files, if one wants to remove entries from a setting that is parsed as a list (and is not a dependency), such as AssertPathExists= (or e.g. ExecStart= in service units), one needs to first clear the list before re-adding all entries except the one that is to be removed. Dependencies (After=, etc.) cannot be reset to an empty list, so dependencies can only be added in drop-ins. If you want to remove dependencies, you have to override the entire unit.
So in your example, your override.conf file should clear out the settings for OnBootSec and OnUnitInactiveSec like so:
Thank you for the response. Your proposed solution makes sense. I had assumed the override would replace the existing configuration. Based on the documentation link you provided, this is not the case. I will modify my override to clear out the existing settings. If it works, I will mark your post as the answer.
While I shared the man page for systemd.unit, the man page for systemd.timer has similar language, see systemd.timer
If the empty string is assigned to any of these options, the list of timers is reset (both monotonic timers and OnCalendar= timers, see below), and all prior assignments will have no effect.
Additionally, you can check when the timer will fire with systemctl list-timers. With the override.conf file I offered in place, I can confirm that the timer will fire every Tuesday:
$ systemctl list-timers rpm-ostreed-automatic
NEXT LEFT LAST PASSED UNIT ACTIVATES
Tue 2024-09-24 05:00:00 EDT 6 days Tue 2024-09-17 07:47:33 EDT 2h 29min ago rpm-ostreed-automatic.timer rpm-ostreed-automatic.service
1 timers listed.
Pass --all to see loaded but inactive timers, too.