您的位置:首页 > 运维架构 > Shell

shell 代码 进程监控脚本,拉起core dump的服务器进程,以维持服务稳定

2009-04-22 14:17 726 查看
#!/bin/sh

# 进程监控脚本,作用是拉起core dump的服务器进程,以维持服务稳定。

HOME="/tmp/ggg/"
PROG="xxx_server"
LOGFILE="monitor.log"

ulimit -c unlimited

while true
do
# restart the PROGRESS if it's dead.
PROG_NUM=`ps -ef | grep $PROG | grep -v "grep"| wc -l`
if test $PROG_NUM -lt 1
then
date +"[%Y-%m-%d %H:%M:%S]" >> $LOGFILE
echo "$PROG is dead." >> $LOGFILE
cd $HOME/bin/
./$PROG start
echo "restart the progress..." >> $LOGFILE
echo >> $LOGFILE
fi

sleep 5
done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息