lundi 2 février 2015

Shell script to restart a certain process if it is not responding


I need an java application to run 24/7 on my mac. Unfortunately the JVM process sometimes gets stuck and thus the java application does not respond anymore.


Is there a possebility to detect if a given process has crashed (or at least is not in a proper running state) and restart this specific process subsequent?


I found



ps aux|grep java


which lists the java process (/usr/bin/java)


Now I need to know how to watch the process state codes and how to restart this particular process in e.g. a shell script.


BTW, the process state is T which means stopped as far as I know.


EDIT: Unfortunately four suggestions didn't work on my machine. I configured an global agent and the jar is starting properly but the process still fails after a certain period of time. Strangely enough the process in activity monitor is not marked as not responding, whereas the context menu of the dock item does (see figure) enter image description here





Aucun commentaire:

Enregistrer un commentaire