正如中所解释的GoAccess 1.4详细教程,我创建了一个 goa-daily.timer
[Unit]
Description=Daily update of GoAccess reports
[Timer]
# Every day @ 3 O'clock
OnCalendar=*-*-* 03:00:00
RandomizedDelaySec=7200
Persistent=true
Unit=goa-daily.service
[Install]
WantedBy=timers.target
无论我如何定义该OnCalendar
选项,当我检查计时器状态时,它总是有一个Trigger: n/a
,而所有其他计时器都有一个触发器。
root@scw:/etc/systemd/system/timers.target.wants# ll
total 0
lrwxrwxrwx 1 root root 35 sep 28 2020 apt-daily.timer -> /lib/systemd/system/apt-daily.timer
lrwxrwxrwx 1 root root 43 sep 28 2020 apt-daily-upgrade.timer -> /lib/systemd/system/apt-daily-upgrade.timer
lrwxrwxrwx 1 root root 33 nov 30 2020 certbot.timer -> /lib/systemd/system/certbot.timer
lrwxrwxrwx 1 root root 35 fév 23 23:01 goa-daily.timer -> /etc/systemd/system/goa-daily.timer
lrwxrwxrwx 1 root root 35 sep 28 2020 logrotate.timer -> /lib/systemd/system/logrotate.timer
lrwxrwxrwx 1 root root 32 sep 28 2020 man-db.timer -> /lib/systemd/system/man-db.timer
root@scw:/etc/systemd/system/timers.target.wants# systemctl status goa-daily.timer
● goa-daily.timer - Daily update of GoAccess reports
Loaded: loaded (/etc/systemd/system/goa-daily.timer; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-01-31 15:43:42 UTC; 3 weeks 2 days ago
Trigger: n/a
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
root@scw:/etc/systemd/system/timers.target.wants# systemctl status logrotate.timer
● logrotate.timer - Daily rotation of log files
Loaded: loaded (/lib/systemd/system/logrotate.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Tue 2022-01-04 08:00:34 UTC; 1 months 20 days ago
Trigger: Thu 2022-02-24 00:00:00 UTC; 49min left
Docs: man:logrotate(8)
man:logrotate.conf(5)
为什么我的计时器不显示任何触发器?我已启用它:systemctl enable --now goa-daily.timer
我还应该做什么才能使用触发器运行计时器?我使用的是 Debian 10 (buster)
goa-daily.service 的状态
# systemctl status goa-daily.service
● goa-daily.service - Application
Loaded: loaded (/etc/systemd/system/goa-daily.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2022-01-31 16:08:54 UTC; 3 weeks 2 days ago
Main PID: 17337 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 2347)
Memory: 0B
CGroup: /system.slice/goa-daily.service
谢谢@模糊绘图评论,我注意到这daemon-reload
对计时器更改没有影响。stop
计时器start
添加了触发器!
# systemctl stop goa-daily.timer
# systemctl start goa-daily.timer
# systemctl status goa-daily.timer
● goa-daily.timer - Daily update of GoAccess reports
Loaded: loaded (/etc/systemd/system/goa-daily.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Thu 2022-02-24 08:51:34 UTC; 4s ago
Trigger: Thu 2022-02-24 08:54:00 UTC; 2min 21s left
但是运行计时器后,状态显示一个/一个触发器,至少具有 OnCalendar 日期时间定义,例如OnCalendar=*-*-* 08:54:00
.
# systemctl status goa-daily.timer
● goa-daily.timer - Daily update of GoAccess reports
Loaded: loaded (/etc/systemd/system/goa-daily.timer; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-02-24 08:51:34 UTC; 2min 30s ago
Trigger: n/a
我错过了什么让它每天重复???我将使用每日选项进行测试并明天检查......
答案1
从服务的显示来看,状态为活动状态。我相信你的计时器不会触发正在运行的服务单元。服务单元可能由于某种原因失败,但系统不知道,或者它已被编码为在结束后保持活动状态。