Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top