$ crontab -l
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /global/weblogic-data/bea/user_projects/domains/TFHBEA/WeblogicDeamon.sh > /dev/null 2>&1
注:红色部分是为了不向用户发送mail
$ cat /global/weblogic-data/bea/user_projects/domains/TFHBEA/WeblogicDeamon.sh
#! /usr/bin/sh
#WebLogic deamon
WebLogicDir="/global/weblogic-data/bea/user_projects/domains/TFHBEA/"
LogDir="${WebLogicDir}servers/TFHWEB/logs/"
LogFileName="TFHBEA.log"
#定位进程号的关键字1
key1="weblogic-data"
#定位进程号的关键字2
key2="jdk150_04"
filenames=`ls ${LogDir} |grep ${LogFileName}`
for filename in $filenames; do
errorkey=`grep "<BEA-002623>" ${LogDir}${filename}`
if [ -n "$errorkey" ];then
pid=`ps -ef|grep ${key1}|grep ${key2}|cut -b10-14`
if [ -n "${pid}" ] ;then
kill -9 ${pid}
sleep 30
fi
rm ${LogDir}${filename}
now=`date +'%Y-%m-%d %H:%M:%S'`
echo "Find <BEA-002623> error in ${filename} on ${now}." >> ${WebLogicDir}WeblogicError.log
fi
done
pid=`ps -ef|grep ${key1}|grep ${key2}|cut -b10-14`
if [ ! -n "${pid}" ] ;then
#将服务加载到后台运行
(${WebLogicDir}bin/startWebLogic.sh &)
now=`date +'%Y-%m-%d %H:%M:%S'`
echo "WebLogic Server is STOP. We start it on ${now}." >> ${WebLogicDir}WeblogicError.log
else
now=`date +'%Y-%m-%d %H:%M:%S'`
echo "WebLogic Server is OK on ${now}." > ${WebLogicDir}WeblogicInfo.log
fi
posted on 2012-02-02 16:26
身在半空 阅读(1590)
评论(0) 编辑 收藏