大网数据广告活动
服务器运维问答

Systemd timer OnCalendar every minute ending with 5

· 52CE 我爱测

With OnCalendar systemd timer i can create something like this to run every 5 minutes. OnCalendar=*:0/5 Is it possible to run it at every minute ending at 5 (00:05, 00:15, 00:25...) only? And/or at every minute ending with a 0 (0…

问题原文

原帖链接 · CrazyRabbit · CC BY-SA 4.0

With OnCalendar systemd timer i can create something like this to run every 5 minutes.

OnCalendar=*:0/5

Is it possible to run it at every minute ending at 5 (00:05, 00:15, 00:25...) only?

And/or at every minute ending with a 0 (00:00, 00:10, 00:20...) only?

Main goal is to have a timer on 2 server, so each one runs at spare times; in case one fails, the other will at least run every 10 minutes (instead of 5).

已采纳解答

原帖链接 · Pascal Pixel Rigaux · CC BY-SA 4.0

Solution:

OnCalendar=*:5/10

which is equivalent to *:5,15,25,35,45,55.

To be sure of the result, use something like:

systemd-analyze calendar --iterations=8 '*:5/10' | grep Iter
       Iter. #2: Sun 2022-02-20 00:25:00 CET
       Iter. #3: Sun 2022-02-20 00:35:00 CET
       Iter. #4: Sun 2022-02-20 00:45:00 CET
       Iter. #5: Sun 2022-02-20 00:55:00 CET
       Iter. #6: Sun 2022-02-20 01:05:00 CET
       Iter. #7: Sun 2022-02-20 01:15:00 CET
       Iter. #8: Sun 2022-02-20 01:25:00 CET

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-03-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。