zoukankan      html  css  js  c++  java
  • 批量操作Tomcat Shell脚本

    1. 批量操作Tomcat Shell脚本_1.sh

    #!/bin/bash  
    
    tom="/opt/ronghelist" 
    product=$1
    usage="{gongcheng1|all} {start|stop|restart|status}" 
     
    if [ "$1" == "" -o "$2" == "" ];then  
        echo "Usage: $0 $usage"  
        exit 1  
    fi  
    
    # 按项目启动(参数:项目名称)
    singlestart() {
        singlestop $1
        for file in `ls $tom"/"$1`
        do    
            echo "---------------------->正在启动"$tom"/"$1"/"$file"融合版"
            if [ -x $tom"/"$1"/"$file"/bin/startup.sh" ]
            then
                $tom"/"$1"/"$file"/bin/startup.sh"
                echo "启动成功"$file
            else
                echo "未发现可执行的"$file"/bin/startup.sh"
            fi
        done
    }
    
    # 按项目停止(参数:项目名称)
    singlestop() {
        for file in `ls $tom"/"$1`
        do
            echo "---------------------->正在停止"$tom"/"$1"/"$file"融合版(旧)"
            tomcatpid=`ps -ef | grep $tom"/"$1"/"$file"/" | grep -v grep | awk '{print $2}'`
            if [ ! -z $tomcatpid  ]
            then
                kill -9 $tomcatpid
            fi
        done
    }
    
    #启动
    tomcatstart() {  
        case $product in
            "all")
                for ronghesub in `ls $tom`
                do
                    singlestart $ronghesub
                done;;
            *)
                if [ -d $tom"/"$product ]
                then
                    singlestart $product
                else
                    echo "未发现指定项目:"$tom"/"$product
                fi;;
        esac
    }  
    #停止
    tomcatstop() {  
        case $product in
            "all")
                for ronghesub in `ls $tom`
                do
                    singlestop $ronghesub
                done;;
            *)
                if [ -d $tom"/"$product ]
                then
                    singlestop $product
                else
                    echo "未发现指定项目:"$tom"/"$product
                fi;;
        esac
    }  
    
    case $2 in  
        "start")
            tomcatstart;;
        "stop")
            tomcatstop;;
        *)
            echo "Usage: $0 $usage";;
    esac  

    2. 文件夹结构图

    3. 操作方式

    # 启动所有项目下的工程
    sh ./1.sh all start
    # 启动项目"gongcheng2"文件夹下的所有tomcat
    sh ./1.sh gongcheng2 start
    # 停止所有项目下的工程
    sh ./1.sh all stop
    # 停止项目"gongcheng2"文件夹下的所有tomcat
    sh ./1.sh gongcheng2 stop
  • 相关阅读:
    unity3d 中文乱码解决方法——cs代码文件格式批量转化UTF8
    Unity SteamVR插件集成
    Unity3D Layer要点
    Unity利用Sapi进行windows语音开发
    Scratch入门课程(1)——把工具准备好
    【blockly教程】Blockly编程案例
    【blockly教程】第六章 Blockly的进阶
    【blockly教程】第五章 循环结构
    【blockly教程】第三章Blockly顺序程序设计
    【blockly教程】第四章 Blockly之选择结构
  • 原文地址:https://www.cnblogs.com/yifanSJ/p/14083691.html
Copyright © 2011-2022 走看看