#!/bin/bash
#
# Watch Dog cron job for app
#
#unset DISPLAY
export LANG=C
PATH=$HOME/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/sfw/bin:/opt/csw/bin:/usr/sfw/sbin
#echo $PATH >> /export/home/project/tmp/log
workdir=$HOME/zn/
LOGFILE=$HOME/tmp/watchdog.log
gdslog=$HOME/builds/gdslobby/log/gdslobby.log
sys_timestamp=`date +%s`
dt=`date '+%Y-%m-%dT%H:%M:%S'`
cd $workdir
#gds_timestamp=`tail -1 $gdslog | gawk -F, '{print $1}' | perl w.pl`
gds_timestamp=`stat $gdslog | grep "Modify" | gawk '{print $2,$3}' | cut -f1 -d"." | perl w.pl`
sys_timestamp=`date '+%Y-%m-%d %H:%M:%S' | perl w.pl`
let difference=$sys_timestamp-$gds_timestamp
echo "$sys_timestamp $gds_timestamp $difference" >> /export/home/project/tmp/log
[ $difference -lt 60 ] && echo "$dt : gdslobby OK" >>$LOGFILE && exit 0
echo "$dt : gdslobby dead! " >>$LOGFILE
gdslobby stop >/dev/null 2>&1
gdslobby start >/dev/null 2>&1
# send mail to admin
cat <
Dear Admin,
'app' process was found to be dead at $dt.
The watchdog restarted .
The WatchDog
EOF
阅读(700) | 评论(0) | 转发(0) |