#!/bin/ksh # # This script is to check if the process "xxx" is running, # if not, will inform admin to re-start it. # Written by Colin Wang # Date: July. 19, 1998 # HOSTNAME=`uname -n` ps -ef -o args |grep xxx |grep -v grep >/tmp/rep LINE=`cat /tmp/rep | wc -l` if [ $LINE = 1 ] then ps -ef -o pid,etime,time,comm,args | grep -v grep | grep -v fsflush | grep -v rpc >/tmp/rep ort head -1 /tmp/report > /tmp/rep1 grep xxx /tmp/report >> /tmp/rep1 mailx -s "The process xxx is running!" admin@xxxyyy.com < /tmp/rep1 else echo "The process xxx may be stopped on $HOSTNAME!!!" >/tmp/rep2 echo "Please check... and re-start it!" >> /tmp/rep2 mailx -s "The process xxx may be stopped!" admin@xxxyyy.com < tmp/rep2 fi sleep 5 rm -f /tmp/report /tmp/rep /tmp/rep1 /tmp/rep2