Systemd-Timer

Systemd 計時器不會觸發

  • January 18, 2021

我在 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.timersystemctl enable --now apt-daily.timer並且systemctl restart timers.target,沒有效果。該命令返回沒有錯誤,但沒有任何變化。

我不知道如何進一步調試,任何提示將不勝感激。

發現我的問題,我需要升級 systemd。當然,這是工作應該做的……

引用自:https://unix.stackexchange.com/questions/629362