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 552E Vanya and Brackets(枚举 + 表达式计算)
    matlab 文件打开设置
    boot and loader
    centos6安装bochs
    Python list, dict, set, tuple
    Python 字符串
    Visual Studio 使用
    汇编语言版本的HelloWorld
    用汇编实现add函数
    使用nasm和clang
  • 原文地址:https://www.cnblogs.com/guanghe/p/10372926.html
Copyright © 2011-2022 走看看