2

This is what I have so far:

until python MyApp.py; do
  echo "App crashed... restarting..." >&2
  sleep 1
done

This will re-run the program when it crashes, but not when the program finishes on its own.

  • 1
    Do you have a question? – Stephen Harris Jul 26 '16 at 13:56
  • So it should always run and show an error message for failures? Maybe use exit codes in an IF-loop with an infinite WHILE-loop as a wrapper. – Fiximan Jul 26 '16 at 13:59
3

Maybe this would do the trick for you ?

while True;
do
 python MyApp.py || echo "App crashed... restarting..." >&2
 echo "Press Ctrl-C to quit." && sleep 1
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.