systemd에서 Restart=no를 사용해도 실행하려는 Linux 서비스가 종료되었다가 다시 시작되지 않습니다.

systemd에서 Restart=no를 사용해도 실행하려는 Linux 서비스가 종료되었다가 다시 시작되지 않습니다.
    Jul 01 16:47:17 server start.sh[21353]: Operation successfully completed
Jul 01 16:47:17 server start.sh[21353]: Saving 5 titles into directory ./raw
Jul 01 17:17:48 server start.sh[21353]: 5 titles saved
Jul 01 17:17:48 server start.sh[21353]: Copy complete. 5 titles saved.
Jul 01 17:17:48 server start.sh[21353]: title_t00.mkv
Jul 01 17:17:49 server start.sh[21353]: MOVIE
Jul 01 17:17:50 server systemd[1]: Started DVD-Ripper.
Jul 01 17:17:50 server start.sh[8906]: MakeMKV v1.14.4 linux(x64-release) started
Jul 01 17:17:52 server start.sh[8906]: Failed to open disc
Jul 01 17:17:52 server start.sh[8906]: Movie.mkv
Jul 01 17:17:52 server start.sh[8906]: rm: cannot remove '*.mkv': No such file or directory

.service 파일에서 Restart=no를 설정했는데도 다음과 같이 서비스가 계속 다시 시작됩니다.

[Unit]
Description=DVD-Ripper

[Service]
ExecStart=/mnt/DVD/MakeMKV/start.sh
KillMode=mixed
SendSIGKILL=no
User=root
Restart=no

왜 이런 일이 일어나는지 아는 사람이 있나요?


이것은 Journalctl -u DVD-Ripper를 사용한 로그입니다.

Jul 01 16:46:30 server start.sh[21353]: MakeMKV v1.14.4 linux(x64-release) started
Jul 01 16:46:33 server start.sh[21353]: Using direct disc access mode
Jul 01 16:46:39 server start.sh[21353]: Title #1 was added (25 cell(s), 0:47:07)
Jul 01 16:46:40 server start.sh[21353]: Title #1/0/1 was added (5 cell(s), 0:24:19)
Jul 01 16:46:41 server start.sh[21353]: Title #1/0/2 was added (5 cell(s), 0:24:18)
Jul 01 16:46:41 server start.sh[21353]: Title #2 was added (25 cell(s), 0:47:07)
Jul 01 16:46:41 server start.sh[21353]: Title #3 was added (5 cell(s), 0:24:19)
Jul 01 16:46:41 server start.sh[21353]: Title #4 was added (5 cell(s), 0:24:18)
Jul 01 16:47:08 server start.sh[21353]: Title #7 was added (5 cell(s), 0:04:59)
Jul 01 16:47:08 server start.sh[21353]: Title #8 was added (5 cell(s), 0:04:59)
Jul 01 16:47:08 server start.sh[21353]: Title #9 has length of 36 seconds which is less tha
Jul 01 16:47:08 server start.sh[21353]: Title #10 has length of 53 seconds which is less th
Jul 01 16:47:09 server start.sh[21353]: Title #11 has length of 26 seconds which is less th
Jul 01 16:47:09 server start.sh[21353]: Title #12 was added (1 cell(s), 0:02:22)
Jul 01 16:47:09 server start.sh[21353]: Title #13 has length of 99 seconds which is less th
Jul 01 16:47:09 server start.sh[21353]: Title #14 has length of 25 seconds which is less th
Jul 01 16:47:10 server start.sh[21353]: Title #15 has length of 111 seconds which is less t
Jul 01 16:47:10 server start.sh[21353]: Title #16 has length of 62 seconds which is less th
Jul 01 16:47:10 server start.sh[21353]: Title #17 has length of 33 seconds which is less th
Jul 01 16:47:10 server start.sh[21353]: Title 1 in VTS 3 is equal to title 4 and was skippe
Jul 01 16:47:11 server start.sh[21353]: Title 2 in VTS 3 is equal to title 4 and was skippe
Jul 01 16:47:11 server start.sh[21353]: Title 3 in VTS 3 is equal to title 4 and was skippe
Jul 01 16:47:11 server start.sh[21353]: Title 4 in VTS 5 is equal to title 3 and was skippe
Jul 01 16:47:17 server start.sh[21353]: Operation successfully completed
Jul 01 16:47:17 server start.sh[21353]: Saving 5 titles into directory ./raw
Jul 01 17:17:48 server start.sh[21353]: 5 titles saved
Jul 01 17:17:48 server start.sh[21353]: Copy complete. 5 titles saved.
Jul 01 17:17:48 server start.sh[21353]: title_t00.mkv
Jul 01 17:17:49 server start.sh[21353]: MOVIE
Jul 01 17:17:50 server systemd[1]: Started DVD-Ripper.
Jul 01 17:17:50 server start.sh[8906]: MakeMKV v1.14.4 linux(x64-release) started
Jul 01 17:17:52 server start.sh[8906]: Failed to open disc
Jul 01 17:17:52 server start.sh[8906]: MOVIE.mkv
Jul 01 17:17:52 server start.sh[8906]: rm: cannot remove '*.mkv': No such file or directory

파일의 ExecStart는 다음과 같습니다.

#!/bin/bash
cd /mnt/DVD/MakeMKV/
makemkvcon mkv disc:0 all ./raw
cd ./raw
file=$(ls -S | head -1)
echo $file
mv "$file" ./final
rm *.mkv
mv ./final/* ./
DVD_NAME=$(udevadm info -n sr1 -q property | sed -n 's/^ID_FS_LABEL=//p')
echo $DVD_NAME
mv ./*.mkv ./$DVD_NAME.mkv
eject sr1

이것이 트리거입니다:

KERNEL=="sr1", ACTION=="change",ENV{ID_CDROM_MEDIA_DVD}="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/mnt/DVD/MakeMKV/trigger.sh"

Trigger.sh에는 다음이 포함됩니다.

systemctl start DVD-Ripper

편집 - UDEV 트리거는 삽입 및 제거 시 모두 실행됩니다. DVD 삽입만 확인하도록 트리거를 수정하려면 어떻게 해야 합니까?

답변1

도움을 주셔서 감사합니다. 결국 Trigger.sh 파일을 수정하고 udev 트리거를 변경하지 않고 그대로 두어 이 문제를 해결했습니다. Trigger.sh에 있는 내용은 다음과 같습니다.

#!/bin/bash
cd /mnt/DVD/MakeMKV/
info=$(blkid -o value -s TYPE /dev/sr1)
type=$(echo 'udf')
echo $info
echo $type
if [ "$info" == "$type" ]
then
systemctl start DVD-Ripper
fi

유형을 확인하고 udf인지 확인합니다. DVD가 삽입되지 않은 경우 $info는 공백을 반환하고 삽입 시 "udf"와 동일하므로 삽입 시 if 문이 true가 됩니다.

도와주셔서 감사합니다!

답변2

Udev를 사용하면 하드웨어 이벤트(이 경우 , , ) 에 반응할 ACTION수 있습니다 .addremovechange

ACTION=="change"DVD를 삽입하거나 꺼낼 때 트리거됩니다.

다음 규칙을 시도해 보세요.

KERNEL=="sr1", ACTION=="add",ENV{ID_CDROM_MEDIA_DVD}="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/mnt/DVD/MakeMKV/trigger.sh"

관련 정보