我正在配置 dnf-automatic 以自动在一些低优先级测试箱上安装安全更新。最终,我希望更新在每个星期日早上 4-5 点左右运行,但出于测试目的,我已将测试箱配置为在星期三下午 14:xx 开始更新,并暂时将任何随机化降至最低。启动后,第一次更新确实会按计划时间运行,但如果我随后查看 systemd 中的计时器状态,则下一次运行的计划时间是第二天早上 6 点。我理解这是 dnf-automatic 默认执行的时间,可能有些关系,但我没有看到我的配置中引用了这一点:
● dnf-automatic-install.timer - dnf-automatic-install timer
Loaded: loaded (/usr/lib/systemd/system/dnf-automatic-install.timer; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/dnf-automatic-install.timer.d
└─override.conf
Active: active (waiting) since Wed 2023-12-06 14:45:31 GMT; 20min ago
**Trigger: Thu 2023-12-07 06:00:02 GMT; 14h left**
Dec 06 14:45:31 dcbutlpocglog5.zonalconnect.local systemd[1]: Started dnf-automatic-install timer.
相关配置文件如下:
[root@dcbutlpocglog5 ~]# cat /etc/systemd/system/dnf-automatic-install.timer.d/override.conf
[Unit]
Description=dnf-automatic-install timer
# See comment in dnf-makecache.service
ConditionPathExists=!/run/ostree-booted
Wants=network-online.target
[Timer]
OnCalendar=Wed 14:51
RandomizedDelaySec=5s
Persistent=true
[Install]
WantedBy=timers.target
[root@dcbutlpocglog5 ~]# cat /etc/dnf/automatic.conf
[commands]
upgrade_type = security
[emitters]
emit_via = motd
[install]
upgrade_requirements_on_install = yes
download_updates = yes
apply_updates = yes
gpgcheck = 1
emit_via = motd
random_sleep = 5
reboot = yes
谁能告诉我为什么会发生这种情况,并帮助我防止在配置之外运行额外的更新?
谢谢
答案1
找到修复方法,看来 SystemD 计时器是可添加的,并且需要在自己的计时器前面添加一个额外的空白“OnCalendar=”参数来清除正常计时器:
[Timer]
OnCalendar=
OnCalendar=Wed 14:51
RandomizedDelaySec=5s
Persistent=true
结果:
[root@dcbutlpocglog5 ~]# systemctl status dnf-automatic-install.timer
● dnf-automatic-install.timer - dnf-automatic-install timer
Loaded: loaded (/usr/lib/systemd/system/dnf-automatic-install.timer; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/dnf-automatic-install.timer.d
└─override.conf
Active: active (waiting) since Wed 2023-12-06 14:45:31 GMT; 20h ago
**Trigger: Wed 2023-12-13 14:51:03 GMT; 6 days left**