#!/bin/csh -f # # restartit.sh - Restart a processes by name # # written by Kevin P. Inscoe (kevin@inscoe.org) (6/17/98) # # # global variables # @ SLEEP_INTERVAL = 5 * 60 # last hour of the day (24 hour) to run set lastrun = 23 @ lastsum = 0 # # Announce ourselves # /bin/echo $0 "starting at `/usr/bin/date`" top: # # find our processes and make sure he is awake... # echo $1 #set restart = `/bin/ps -ef | /bin/grep $1 | /bin/grep -v 'grep'` set restart = `/bin/ps -ef | /bin/grep $1` echo "----" echo $restart goto exit if ( $status != '0' ) then # Check to see if we are still in our window... set hour = `/usr/bin/date '+%H'` if ( $hour < $lastrun ) then sleep $SLEEP_INTERVAL goto top endif exit: # # our tour of duty is over..time to bail # /bin/echo "lastrun completed...exiting at `/usr/bin/date`" exit 0