Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
「mm.out」のような名前のバイナリプログラムがあります。このプログラムにはいくつかの予期しないバグがあり、バグが原因でプログラムが停止します。バイナリが予期せず停止した場合に再度バイナリを実行するサービスまたはシェル スクリプトを作成したいと考えています。このプログラムはどのように書けばよいのでしょうか?
プログラムを修正する必要があります。ただし、これが本当に必要な場合は、ループで実行します。
while ! mm.out do sleep 5 # Just in case the program dies immediately done
シェル スクリプトにそれを実行させ、戻りコードが返されるのを待ちます。そのコードが 0 でない場合は、プログラムを再起動します。