アプリケーションを実行し続けるウォッチドッグスクリプト

アプリケーションを実行し続けるウォッチドッグスクリプト

私は現在、Linuxサーバー上でMxEasyというアプリケーションを使用して複数のIPカメラのビデオを表示しています。ソフトウェアには多くのバグがあり、時にはクラッシュが発生します。アプリケーションが実行中であることを確認し、そうでなければ...アプリケーションを起動するスクリプトを作成しました。

スクリプトを実行するためにcrontabにこの行を追加してみました。スクリプトを実行していますが、MxEasyは起動しません。私が気づいていない部分がありますか?

0,15,30,45,50 * * * * root  export DISPLAY=:0 && /etc/cron.hourly/MxEasyCheck.sh 

ところで、Ubuntu Server 12.04はオペレーティングシステムです。

MxEasyCheck.sh です。

MXEASY=$(ps -A | grep -w MxEasy)

if ! [ -n "$MXEASY" ] ; then
    /home/emuser/bin/MxEasy/startMxEasy.sh &
    exit
fi

これは私のクローンタブです。

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
0  *    * * *   root    /etc/cron.hourly/rsynccheck.sh
0,15,30,45,50 * * * * root  export DISPLAY=:0 && /etc/cron.hourly/MxEasyCheck.sh 
#

ベストアンサー1

数分ごとに確認するのではなく、プログラムが異常終了した場合に再起動するループを作成してください。しかし、自分でそうしないでください。これを実行できる既存のプログラムがたくさんあります。バラよりプロセスが常に実行されていることを確認してください。

おすすめ記事