我在 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
并且分析似乎同意语法很好:
# 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)
所以解决方案最终正是我试图解决的问题......我不得不将 systemd 升级到最新版本。我想我遇到了一个在更高版本中解决的错误。