문제

I have a binary program named as some thing like "mm.out". This program has some unexpected bugs and the bugs causes it to stop. I want to write a service or shell script to execute my binary again if it stopped unexpectedly. How should I write this program?

도움이 되었습니까?

해결책

You should fix the program. But if you really want this, run it in a loop:

while ! mm.out
do
    sleep 5    # Just in case the program dies immediately
done

다른 팁

Let a shell script execute it and wait for a return code, if that code isn't 0 restart the program.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top