我在 Debian Buster 上遇到了一个非常奇怪的问题。我已经在服务器上启用了无人值守升级,因为这是一个非常基本的服务器,它应该会自动更新。然而,似乎这个的 apt 计时器从未启动过。
当我检查所有计时器时,我得到以下信息:
# systemctl list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Fri 2021-01-15 20:00:00 UTC 58min left Fri 2021-01-15 19:00:00 UTC 1min 13s ago logrotate.timer logrotate.service
Sat 2021-01-16 00:00:00 UTC 4h 58min left Fri 2021-01-15 00:00:00 UTC 19h ago man-db.timer man-db.service
Sat 2021-01-16 18:03:26 UTC 23h left Fri 2021-01-15 18:03:26 UTC 57min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
n/a n/a Thu 2020-11-26 06:15:45 UTC 1 months 20 days ago apt-daily-upgrade.timer apt-daily-upgrade.service
n/a n/a Wed 2020-11-25 20:32:27 UTC 1 months 20 days ago apt-daily.timer apt-daily.service
当我检查计时器的定义时,它看起来很好:
# systemctl cat apt-daily.timer
# /lib/systemd/system/apt-daily.timer
[Unit]
Description=Daily apt download activities
[Timer]
OnCalendar=*-*-* 6,18:00
RandomizedDelaySec=12h
Persistent=true
[Install]
WantedBy=timers.target
并且 analyze 似乎同意语法没有问题:
# systemd-analyze calendar "*-*-* 6,18:00"
Original form: *-*-* 6,18:00
Normalized form: *-*-* 06,18:00:00
Next elapse: Sat 2021-01-16 06:00:00 UTC
From now: 10h left
但它们没有触发。我尝试运行systemctl start apt-daily.timer
和systemctl enable --now apt-daily.timer
,systemctl restart timers.target
没有效果。命令返回时没有错误,但没有任何变化。
我不知道如何进一步调试它,如能提供任何提示我将非常感激。
编辑根据要求,apt-daily.service单元的内容:
# /lib/systemd/system/apt-daily.service
[Unit]
Description=Daily apt download activities
Documentation=man:apt(8)
ConditionACPower=true
After=network.target network-online.target systemd-networkd.service NetworkManager.service connman.service
[Service]
Type=oneshot
ExecStartPre=-/usr/lib/apt/apt-helper wait-online
ExecStart=/usr/lib/apt/apt.systemd.daily update
编辑该服务本身也没有被禁用,但是dead
:
# systemctl status apt-daily.service
● apt-daily.service - Daily apt download activities
Loaded: loaded (/lib/systemd/system/apt-daily.service; static; vendor preset: enabled)
Active: inactive (dead)
Docs: man:apt(8)
答案1
所以最终的解决方案正是我想要解决的问题... 我必须将 systemd 升级到最新版本。我想我遇到了一个在更高版本中得到解决的错误。