사용자로서 매분 시스템 타이머를 실행하려고 하는데 초기 트리거 이후에는 반복되지 않습니다. 1분마다 트리거 ffmpeg-timelapse.timer
되도록 구성되었으며 종속 서비스 입니다 . 이를 통해 타임랩스 구성에서 카메라를 쉽게 추가/제거할 수 있습니다.OnCalendar=minutely
ffmpeg-timelapse.target
WantedBy
내가 겪고 있는 문제는 장치를 시작할 때 ffmpeg-timelapse.timer
다음 분 동안 장치를 예약하지만 반복되지 않는다는 것입니다. 인수로 시작하면 동일한 문제가 발생합니다 --now
.
ffmpeg-timelapse.timer
[Unit]
Description=Runs ffmpeg timelapse units every minute
[Timer]
OnCalendar=minutely
Unit=ffmpeg-timelapse.target
[Install]
WantedBy=timers.target
ffmpeg-timelapse.target
[Unit]
Description=Triggers the individual timelapse units for each camera.
StopWhenUnneeded=yes
카메라 서비스 파일의 예.
ffmpeg-timelapse01-front-yard.service
[Unit]
Description=Front Yard Timelapse Unit
Wants=ffmpeg-timelapse.timer
[Service]
ExecStart=/bin/bash -ac '. camera01.conf ; exec ffmpeg-timelapse.sh'
[Install]
WantedBy=ffmpeg-timelapse.target
서비스를 활성화하고 시작하면 다음 분 동안 서비스가 예약됩니다.
$ systemctl --user start ffmpeg-timelapse.timer
$ systemctl --user list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Sat 2020-06-06 12:08:00 EDT 12s left n/a n/a ffmpeg-timelapse.timer ffmpeg-timelapse.target
1 timers listed.
Pass --all to see loaded but inactive timers, too.
그러나 한 번 실행하면 다시 실행되지 않습니다.
$ systemctl --user list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
n/a n/a Sat 2020-06-06 12:08:42 EDT 1min 2s ago ffmpeg-timelapse.timer ffmpeg-timelapse.target
1 timers listed.
Pass --all to see loaded but inactive timers, too.
이 명령을 실행 중인 사용자가 linger
활성화되었습니다.
$ loginctl show-user timelapse
UID=1000
GID=1000
Name=timelapse
Timestamp=Tue 2020-04-07 16:16:20 EDT
TimestampMonotonic=3291000946930
RuntimePath=/run/user/1000
[email protected]
Slice=user-1000.slice
Display=411982
State=active
Sessions=412092 411982 163185
IdleHint=no
IdleSinceHint=0
IdleSinceHintMonotonic=0
Linger=yes
상태 출력이 올바른 것 같습니다.
$ systemctl --user status ffmpeg-timelapse.target
● ffmpeg-timelapse.target - Triggers the individual timelapse units for each camera.
Loaded: loaded (/home/timelapse/.config/systemd/user/ffmpeg-timelapse.target; static; vendor preset: enabled)
Active: active since Sat 2020-06-06 10:50:42 EDT; 1h 23min ago
$ systemctl --user status ffmpeg-timelapse.timer
● ffmpeg-timelapse.timer - Runs ffmpeg timelapse units every 5 minutes
Loaded: loaded (/home/timelapse/.config/systemd/user/ffmpeg-timelapse.timer; enabled; vendor preset: enabled)
Active: active (running) since Sat 2020-06-06 12:13:25 EDT; 1min 1s ago
$ systemctl --user status ffmpeg-timelapse01-front-yard.service
● ffmpeg-timelapse01-front-yard.service - Front Yard Timelapse Unit
Loaded: loaded (/home/timelapse/.config/systemd/user/ffmpeg-timelapse01-front-yard.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2020-06-06 12:14:03 EDT; 35s ago
Process: 4491 ExecStart=/bin/bash -ac '. camera01.conf ; exec ffmpeg-timelapse.sh'
Main PID: 4491 (code=exited, status=0/SUCCESS)
아래는 출력입니다journalctl -xe
Jun 06 12:13:25 srv01 systemd[26482]: Started Runs ffmpeg timelapse units every minute.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
Jun 06 12:14:02 srv01 systemd[26482]: Started Front Yard Timelapse Unit.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
답변1
출력을 보고 systemctl --user list-units --all ffmpeg*
문제를 확인했습니다 . 남은 ffmpeg-timelapse.target
로드/활동/활동. 이벤트가 실제로 발생하기 전에 설정 ffmpeg-timelapse.timer
하십시오 .SUB
waiting
UNIT LOAD ACTIVE SUB JOB DESCRIPTION
ffmpeg-timelapse.target loaded active active start Triggers the individual timelapse units for each camera.
ffmpeg-timelapse.timer loaded active running Runs ffmpeg timelapse units every minute
결함은 [Unit]
구성 에 있습니다 ffmpeg-timelapse.target
. 구성을 추가 해야 합니다 oneshot
. 그렇지 않으면 대상 장치가 여전히 활성 상태입니다.
$ cat ffmpeg-timelapse.target
[Unit]
Type=oneshot
Description=Triggers the individual timelapse units for each camera.
StopWhenUnneeded=yes
이제 예상대로 매분마다 반복됩니다.
$ systemctl --user list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Sat 2020-06-06 12:58:00 EDT 13s left Sat 2020-06-06 12:57:42 EDT 3s ago ffmpeg-timelapse.timer ffmpeg-timelapse.target
지금 유닛의 모습은 이렇습니다.
UNIT LOAD ACTIVE SUB DESCRIPTION
ffmpeg-timelapse01-front-yard.service loaded inactive dead Front Yard Timelapse Unit
ffmpeg-timelapse.target loaded inactive dead Triggers the individual timelapse units for each camera.
ffmpeg-timelapse.timer loaded active waiting Runs ffmpeg timelapse units every minute
항목별 상태 출력입니다.
$ systemctl --user status ffmpeg-timelapse.timer
● ffmpeg-timelapse.timer - Runs ffmpeg timelapse units every minute
Loaded: loaded (/home/timelapse/.config/systemd/user/ffmpeg-timelapse.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Sat 2020-06-06 12:59:30 EDT; 3min 43s ago
$ systemctl --user status ffmpeg-timelapse.target
● ffmpeg-timelapse.target - Triggers the individual timelapse units for each camera.
Loaded: loaded (/home/timelapse/.config/systemd/user/ffmpeg-timelapse.target; static; vendor preset: enabled)
Active: inactive (dead) since Sat 2020-06-06 13:03:11 EDT; 6s ago
$ systemctl --user status ffmpeg-timelapse01-front-yard.service
● ffmpeg-timelapse01-front-yard.service - Front Yard Timelapse Unit
Loaded: loaded (/home/timelapse/.config/systemd/user/ffmpeg-timelapse01-front-yard.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2020-06-06 13:03:12 EDT; 8s ago
Process: 9607 ExecStart=/bin/bash -ac '. camera01.conf ; exec ffmpeg-timelapse.sh'
Main PID: 9607 (code=exited, status=0/SUCCESS)