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を使用すると、ハードウェアイベント(この場合は、、)に反応できますACTIONaddremovechange

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"

関連情報