我尝试每天使用 systemd 清理我的 docker 注册表:
这是我的文件内容:
[Unit]
Description=registry-gc
[Timer]
OnCalendar=41 15 * * *
Persistent=true
[Install]
WantedBy=timers.target
运行时出现以下错误: sudo systemctl statusregistry-gc.timer
● registry-gc.timer - registry-gc
Loaded: bad-setting (Reason: Unit registry-gc.timer has a bad unit file setting.)
Active: inactive (dead)
Trigger: n/a
Triggers: ● registry-gc.service
/etc/systemd/system/registry-gc.timer:5: Failed to parse calendar specification, ignoring: 41 15 * * *
registry-gc.timer: Timer unit lacks value setting. Refusing.
当我询问 :systemctl list-timers --all 时,我得到:
NEXT LEFT LAST PASSED UNIT ACTIVATES
Fri 2022-09-02 16:34:04 CEST 42min left Fri 2022-09-02 15:34:37 CEST 16min ago anacron.timer anacron.service
Fri 2022-09-02 22:37:19 CEST 6h left Fri 2022-09-02 06:07:37 CEST 9h ago fwupd-refresh.timer fwupd-refresh.service
Sat 2022-09-03 00:00:00 CEST 8h left Fri 2022-09-02 00:00:58 CEST 15h ago logrotate.timer logrotate.service
Sat 2022-09-03 00:00:00 CEST 8h left Fri 2022-09-02 00:00:58 CEST 15h ago man-db.timer man-db.service
Sat 2022-09-03 01:32:55 CEST 9h left Fri 2022-09-02 12:47:34 CEST 3h 3min ago apt-daily.timer apt-daily.service
Sat 2022-09-03 06:40:33 CEST 14h left Fri 2022-09-02 06:49:58 CEST 9h ago apt-daily-upgrade.timer apt-daily-upgrade.service
Sat 2022-09-03 08:48:51 CEST 16h left Fri 2022-09-02 14:38:46 CEST 1h 12min ago motd-news.timer motd-news.service
Sat 2022-09-03 12:09:58 CEST 20h left Fri 2022-09-02 12:09:58 CEST 3h 41min ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Sun 2022-09-04 03:10:16 CEST 1 day 11h left Sun 2022-08-28 03:10:37 CEST 5 days ago e2scrub_all.timer e2scrub_all.service
Mon 2022-09-05 00:00:00 CEST 2 days left Mon 2022-08-29 00:00:58 CEST 4 days ago fstrim.timer fstrim.service
n/a n/a n/a n/a registry-gc.timer registry-gc.service
我使用 cron 格式来设置时间。我想每天 15:41 运行它。任何想法?