#! /Bin/bashNAME = javaNOP =/bin/trueDATE = $ (/bin/date + "% Y-% m-% d % H: % M: % S ") ps-ef | awk-F "" '{print $8, $2}' | grep ^ java & gt;/dev/null2 & gt; & amp; 1 case "$? "In0) # Itisrunninginth
#! /Bin/bash NAME = java NOP =/bin/trueDATE = $ (/bin/date + "% Y-% m-% d % H: % M: % S ") ps-ef | awk-F "" '{print $8, $2}' | grep ^ java>/dev/null 2> & 1 case "$? "In0) # It is running in this case so we do nothing. echo "$ NAME is running OK. relax. "$ NOP; 1) echo" $ NAME is not running. starting $ NAME and sending notices. "java-jar sms. jar 2> & 1>/dev/null & NOTICE =/tmp/watchdog. log echo "$ NAME was not running and was started on $ DATE" >>$ NOTICE esac exit 0
A simple requirement: shell implements the watchdog function of process monitoring. It works with the scheduled task to execute a shell script every minute to monitor the process. If the process is accidentally interrupted, it is started, if it is normal, nothing needs to be done.