시스템 버전 219
우분투 22.04.2 LTS
[Unit]
Description=Run myscript.service every 5 minutes
[Timer]
OnCalendar= *-*-* 10-23:10/5:00
Persistent=true
[Install]
WantedBy=timers.target
23:10까지 매시간 10분마다 서비스를 실행해야 합니다. (10:10, 11:10, 12:10..23:10). 시간의 틀을 정하기가 어렵네요.
나는 열심히 노력했다10-23, 10..23같은 날짜를 다른 사람이 붙여넣어도우편 엽서. 아직도 소용이 없습니다.
실수
Dec 27 16:48:09 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-* 10..23:10/5:00
Dec 27 16:48:09 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
Dec 27 16:52:51 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-*10..23:10/5:00
Dec 27 16:52:51 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
Dec 27 16:55:18 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-* 9-17:00:00
Dec 27 16:55:18 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
Dec 27 16:56:45 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-* 9-18:00:00
Dec 27 16:56:45 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
Dec 27 16:57:59 node1 systemd[1]: [/etc/systemd/system/myscript.timer:5] Failed to parse calendar specification, ignoring: *-*-* 10-23:10/5:00
Dec 27 16:57:59 node1 systemd[1]: myscript.timer lacks value setting. Refusing.
답변1
x..y
다음 버전에서만 시간 범위 구문에 대한 지원이 추가되었습니다.시스템 버전 231.
CHANGES WITH 231:
* Calendar time specifications in .timer units now understand a ".."
syntax for time ranges. Example: "4..7:10" may now be used for
defining a timer that is triggered at 4:10am, 5:10am, 6:10am and
7:10am every day.
이전 버전에서는 매 시간마다 하나씩 여러 설정을 지정하거나 OnCalendar=
스크립트 자체를 변경하여 현재 시간을 확인하고 간격이 초과되면 즉시 종료해야 합니다.