linux shell脚本监控java进程崩溃自动重启

# ! /bin/sh

basepath=$(cd `dirname $0`; pwd)

while true
do
    procnum=`ps -ef|grep "服务名称"|grep -v grep|wc -l`
    if [ $procnum -eq 0 ]
    then
        启动命令
        echo `date +%Y-%m-%d` `date +%H:%M:%S`  "restart 服务" >>$basepath/shell.log
    fi
    sleep 1
done

后台执行 nohup ./shell.sh &

发布了1620 篇原创文章 · 获赞 144 · 访问量 179万+

猜你喜欢

转载自blog.csdn.net/themagickeyjianan/article/details/105334799
今日推荐