0

I have two binary files that I need to run (e.g., hello1 and hello2 and the order has to be hello1 followed by hello2), but from time to time hello2 crashes and when it crashes I need to manually restart hello2. I want a Bash script to keep checking the status of hello1 and hello2 and if either of them crashes then I want to start hello1 and hello2.

On Linux is checking the PIDs of hello1 and hello2 the best way to do this?

1 Answer 1

4

Run the commands directly as the condition of an until loop.

while :; do
   until hello1; do :; done
   until hello2; do :; done
done

If you only need to run each command once, you can omit the enclosing while loop.

The : is a do-nothing command required by the syntax of the loop. All you really want is for the loop to exit once the command has a succesful exit status.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.