Auto-restart process on crash [duplicate]

There's a few options - you could always wrap it in a short shell script like this:-

#!/bin/sh

RC=1
while [ $RC -ne 0 ]; do
   ./my-java-app
   RC=$?
done

Far from elegant, but may suffice.


What you're looking for is usually called process monitoring or process supervision. There are many tools that do this, usually as part of a varying set of features. Upstart is more and more used for system services in the Linux world. Monit is the first thing I'd try for a program not started by root, but there are many alternatives.