Not stopping program (using shell script)
Pergunta
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?
Solução
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
Outras dicas
Let a shell script execute it and wait for a return code, if that code isn't 0 restart the program.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow