#!/bin/bash # Auto restart OpenMCU-ru when it crashes # Author: Nathan Thomas # Date: 04/14/2015 while true do unset var var=$( ps aux | grep "openmcu-ru" | grep -cv "grep" 2>&1 ) if [ "${var}" -eq "1" ] ; then # It's aliiiiiiive...do nothing (bitchslap) : elif [ "${var}" -gt "1" ] ; then # Hmm, multiple instances but why? Comment out if your debugging OpenMCU # and there's a legitimate reason to have multiple processes running simultaneously # Otherwise, Squish bug! kill $( pgrep "openmcu-ru" 2&>1 ) 2&>1 /usr/bin/service openmcu-ru start 2>&1 else # Balls, it's dead /usr/bin/service openmcu-ru start 2>&1 fi sleep .5 done