zoukankan      html  css  js  c++  java
  • Shell批量启动、关闭tomcat

    批量启动tomcat脚本,配置NUM可控制启动数量

     1 #!/bin/bash
     2 
     3 #identifier
     4 CLUSTER_HOME=/opt/cluster-tomcat
     5 TNAME=tomcat-8.5.32-0
     6 TPORT=808
     7 NUM=2
     8 MUTE=" >> /dev/null 2>&1"
     9 COPYRIGHT="~~~~~~~~~~~Powered by GuangSoft"
    10 
    11 #script
    12 for i in `seq 1 $NUM`;
    13 do
    14     netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
    15     if [ $? -ne 0 ]
    16     then
    17         echo -e "
    starting ${TNAME}${i}. $COPYRIGHT
    "
    18         STARTSCRIPT="$CLUSTER_HOME/$TNAME${i}/bin/startup.sh $MUTE"
    19         eval $STARTSCRIPT
    20         netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
    21         if [ $? -ne 0 ]
    22         then
    23         echo -e "
    ${TNAME}${i} has started successful! $COPYRIGHT
    "
    24         else 
    25         echo -e "
    ${TNAME}${i} start failed! $COPYRIGHT
    "
    26         fi
    27     else 
    28         echo -e "
    ${TNAME}${i} is already started! $COPYRIGHT
    "
    29     fi
    30 done

    批量关闭tomcat脚本,配置NUM可控制关闭数量

     1 #!/bin/bash
     2 
     3 #identifier
     4 CLUSTER_HOME=/opt/cluster-tomcat
     5 TNAME=tomcat-8.5.32-0
     6 TPORT=808
     7 NUM=3
     8 MUTE=" >> /dev/null 2>&1"
     9 COPYRIGHT="~~~~~~~~~~~Powered by GuangSoft"
    10 
    11 #script
    12 for i in `seq 1 $NUM`;
    13 do
    14     netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
    15     if [ $? -ne 0 ]
    16     then
    17         echo -e "
    ${TNAME}${i} is already stopped! $COPYRIGHT
    "
    18     else 
    19         echo -e "
    stopping ${TNAME}${i}. $COPYRIGHT
    "
    20         STOPSCRIPT="$CLUSTER_HOME/$TNAME${i}/bin/shutdown.sh $MUTE"
    21         eval $STOPSCRIPT
    22         netstat -ano | grep $TPORT${i} | grep -v grep >> /dev/null 2>&1
    23         if [ $? -ne 0 ]
    24         then
    25         echo -e "
    ${TNAME}${i} stop failed! $COPYRIGHT
    "
    26         else 
    27         echo -e "
    ${TNAME}${i} has stopped successful! $COPYRIGHT
    "
    28         fi
    29     fi
    30 done
  • 相关阅读:
    Codeforces 777B Game of Credit Cards
    Codeforces 777A Shell Game
    零基础学贪心算法
    1283 最小周长
    容斥原理
    Humble Numbers(丑数) 超详解!
    1284 2 3 5 7的倍数
    1305 Pairwise Sum and Divide
    1347 旋转字符串
    HDU 2549 壮志难酬
  • 原文地址:https://www.cnblogs.com/guanghe/p/10372926.html
Copyright © 2011-2022 走看看