zoukankan      html  css  js  c++  java
  • 快速重启tomcat的shell脚本

    今天写了一个定时重启tomcat的脚本

    定时任务:
    
    30 * * * * /bin/bash /root/scripts/auto_restart_tomcat5.sh >> /root/scripts/auto_restart_tomcat5.log 2>&1 &

    首先进行判断进程是否存在,存在则进行kill,不存在则启动;

    如此循环;

    启动后break跳出循环;

    #!/bin/sh#date 2019-12-11#dan si#auto restart tomcat5

    time=`date "+%Y-%m-%d %H:%M:%S"`
    echo -e "
    
    ==============================="
    echo "======$time======"
    echo "==============================="
    serviceName=tomcat5/conf
    pid=`ps -ef | grep $serviceName | grep -v "grep" | awk '{print $2}'`
    #kill -9 $pid
    
    for((i=1;i<100;i++));
    do
    if [ 0 == `ps -ef |grep $serviceName |grep -v "grep" |wc -l` ];then
            echo "$serviceName process is no running!"
            cd /usr/local/tomcat5/
            ./bin/catalina.sh start
            echo "$serviceName process is restart!"
            break
    else
            kill -9 $pid
            echo "$serviceName process is running! It was killed again"
            sleep 1
    fi
    done
    专注
  • 相关阅读:
    JZOJ5809 数羊
    P3313 [SDOI2014]旅行
    2019.10.22 NOIP模拟测试 day2
    P4322 [JSOI2016]最佳团体
    P1850 换教室
    P3225 [HNOI2012]矿场搭建
    P2607 [ZJOI2008]骑士
    2019.10.21 NOIP模拟测试 day1
    AFO
    禁止加载浏览器图片
  • 原文地址:https://www.cnblogs.com/jimmyTang-J/p/12023794.html
Copyright © 2011-2022 走看看