- 已关闭。**此问题为not about programming or software development。当前不接受答案。
此问题似乎与a specific programming problem, a software algorithm, or software tools primarily used by programmers无关。如果您认为此问题与another Stack Exchange site的主题有关,您可以留下评论,说明在何处可以回答此问题。
3天前关闭。
Improve this question
我设置了一个systemd定时器,在每年12月(每年12月01日至25日)的到来时使网页内容 curl ,它在每次启动时运行,我不知道为什么。
以下是~/.config/systemd/user/
目录中的systemd单元:
# ~/.config/systemd/user/advent-of-code.timer
[Unit]
Description=timer for pulling AoC tests
Requires=advent-of-code.service
[Timer]
OnCalendar=*-12-01..25 06:14:01
Unit=advent-of-code.service
Persistent=true
[Install]
WantedBy=timers.target
还有
# ~/.config/systemd/user/advent-of-code.service
[Unit]
Description="Pulls a task for advent of code for a given day"
After=syslog.target network-online.target
Wants=network-online.target
[Service]
Type=oneshot
WorkingDirectory=<some-absolute-home-path>/AoC
ExecStart=<some-absolute-home-path>/AoC/fetch-inputs.sh
(This不应该有任何重要性,但今天我看到我把OnCalendar
日期颠倒了:我用的是1..25-12-*
而不是*-12-1..25
,但即使这样,它也应该只在12月运行...
然后启用计时器并重新加载守护进程:
一个二个一个一个
我使用systemd-analyze
来验证计时器和服务,它通过了,退出代码为0,并检查日历表达式:
$ systemd-analyze verify --user advent-of-code.{service,timer} # return code 0
$ systemd-analyze calendar "*-12-01..25 06:14:01"
Normalized form: *-12-01..25 06:14:01
Next elapse: Fri 2023-12-01 06:14:01 CET
(in UTC): Fri 2023-12-01 05:14:01 UTC
From now: 9 months 22 days left
看起来不错,对吧?
- 但随后查询状态显示,计时器和服务在今天触发,下一次触发计划在12月:**
$ systemctl --user status advent-of-code.timer
● advent-of-code.timer - timer for pulling AoC tests
Loaded: loaded (/home/tooster/.config/systemd/user/advent-of-code.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Tue 2023-02-07 08:56:21 CET; 7h ago
Trigger: Fri 2023-12-01 06:14:01 CET; 9 months 22 days left
Triggers: ● advent-of-code.service
$ systemctl --user status advent-of-code.service
○ advent-of-code.service - "Pulls a task for advent of code for a given day"
Loaded: loaded (/home/tooster/.config/systemd/user/advent-of-code.service; static)
Active: inactive (dead) since Tue 2023-02-07 08:56:23 CET; 7h ago
TriggeredBy: ● advent-of-code.timer
Main PID: 13315 (code=exited, status=0/SUCCESS)
CPU: 184ms
这是怎么回事?
如果相关的话,我先在全局/etc/...
目录中放置了这些定时器,但为了清晰起见,我将它们移到了用户范围,因为它不太想拉东西(可能是因为我没有适当的网络依赖性等)。我在没有禁用的情况下移动了它们,但现在一切似乎都很好(systemctl list-timers/list-units
列出了没有丢失/禁用/无效的advent-of-code
)。
1条答案
按热度按时间daolsyd01#
具有讽刺意味的是,经过几天的斗争与此我只找到了解决方案后,自己张贴到SO😅
基于this answer,我注意到我的
*.timer
文件在定义中有一个Requires=
字段,我假设它作为加载/启动计时器的依赖项启动服务,而不是对它进行操作。删除此条目并仅保留
Unit=
似乎已修复此问题。