zoukankan      html  css  js  c++  java
  • tomcat 启动脚本

    #!/bin/bash
    #
    #干掉运行中的tomcat  results=把结果赋值给变量,可以保证命令上条执行完再执行下一条
    #也可以用这句简单的代码按进程名kill: ps -ef | grep 进程名 | grep -v grep | awk '{print $2}' | xargs kill -9
    results=`ps -ef|grep tomcat|grep -v grep|grep -v PPID|awk '{ print $2}'`
    echo -e 'tomcat PID: ' ${results}
    for i in ${results}
    do
    kill -9 $i
    echo -e "Kill the tomcat process [ $i ]"
    done
    #
    results=`ps -ef|grep tomcat|grep -v grep|grep -v PPID|awk '{ print $2}'`
    echo -e 'tomcat PID: ' ${results}
    #
    #备份
    dqsj=`date "+%Y-%m-%d_%H:%M:%S"`
    results=`/bin/cp -rf /home/tomcat-7.0.85_6001/apps /home/gb/old/apps6001_${dqsj}`
    echo -e ${results}
    results=`/bin/cp -rf /home/tomcat-7.0.85_tslx/apps /home/gb/old/appstslx_${dqsj}`
    echo -e ${results}
    echo -e 'back-up /tomcat/apps/ /home/gb/old/ OK'
    #
    #清空tomcat日志
    results=`/bin/rm -rf /home/tomcat-7.0.85_6001/logs/*`
    echo -e ${results}
    results=`/bin/rm -rf /home/tomcat-7.0.85_6002/logs/*`
    echo -e ${results}
    results=`/bin/rm -rf /home/tomcat-7.0.85_6003/logs/*`
    echo -e ${results}
    results=`/bin/rm -rf /home/tomcat-7.0.85_6004/logs/*`
    echo -e ${results}
    results=`/bin/rm -rf /home/tomcat-7.0.85_tslx/logs/*`
    echo -e ${results}
    echo -e 'delete /tomcat/logs/* OK'
    #
    #清空tomcat缓存
    results=`/bin/rm -rf /home/tomcat-7.0.85_6001/work/Catalina/*`
    echo -e ${results}
    results=`/bin/rm -rf /home/tomcat-7.0.85_6002/work/Catalina/*`
    echo -e ${results}
    results=`/bin/rm -rf /home/tomcat-7.0.85_6003/work/Catalina/*`
    echo -e ${results}
    results=`/bin/rm -rf /home/tomcat-7.0.85_6004/work/Catalina/*`
    echo -e ${results}
    results=`/bin/rm -rf /home/tomcat-7.0.85_tslx/work/Catalina/*`
    echo -e ${results}
    echo -e 'delete /tomcat/work/Catalina/* OK'
    #
    #拷贝工程 节点6001
    results=`/bin/cp -rf /home/gb/new/sfpt.war /home/tomcat-7.0.85_6001/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptpj.war /home/tomcat-7.0.85_6001/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptpu.war /home/tomcat-7.0.85_6001/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptmu.war /home/tomcat-7.0.85_6001/apps/`
    echo -e ${results}
    #
    #拷贝工程 节点6002
    results=`/bin/cp -rf /home/gb/new/sfpt.war /home/tomcat-7.0.85_6002/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptpj.war /home/tomcat-7.0.85_6002/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptpu.war /home/tomcat-7.0.85_6002/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptmu.war /home/tomcat-7.0.85_6002/apps/`
    echo -e ${results}
    #
    #拷贝工程 节点6003
    results=`/bin/cp -rf /home/gb/new/sfpt.war /home/tomcat-7.0.85_6003/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptpj.war /home/tomcat-7.0.85_6003/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptpu.war /home/tomcat-7.0.85_6003/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptmu.war /home/tomcat-7.0.85_6003/apps/`
    echo -e ${results}
    #
    #拷贝工程 节点6004
    results=`/bin/cp -rf /home/gb/new/sfpt.war /home/tomcat-7.0.85_6004/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptpj.war /home/tomcat-7.0.85_6004/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptpu.war /home/tomcat-7.0.85_6004/apps/`
    echo -e ${results}
    results=`/bin/cp -rf /home/gb/new/sfptmu.war /home/tomcat-7.0.85_6004/apps/`
    echo -e ${results}
    #
    #拷贝工程 节点6005
    results=`/bin/cp -rf /home/gb/new/sfpttslx.war /home/tomcat-7.0.85_tslx/apps/`
    echo -e ${results}
    #
    echo -e 'Copy /home/gb/new/ /tomcat/apps/ OK'
    #
    #启动服务
    results=`bash  /home/tomcat-7.0.85_6001/bin/startup.sh`
    echo -e   ${results}
    results=`bash  /home/tomcat-7.0.85_6002/bin/startup.sh`
    echo -e   ${results}
    results=`bash  /home/tomcat-7.0.85_6003/bin/startup.sh`
    echo -e   ${results}
    results=`bash  /home/tomcat-7.0.85_6004/bin/startup.sh`
    echo -e   ${results}
    results=`bash  /home/tomcat-7.0.85_tslx/bin/startup.sh`
    echo -e   ${results}
    echo -e 'startup OK'
    #
    results=`ps -ef|grep tomcat|grep -v grep|grep -v PPID|awk '{ print $2}'`
    echo -e 'tomcat PID: ' ${results}
    #
    dqsj=`date "+%Y-%m-%d %H:%M:%S"`
    echo -e  'endTime ' ${dqsj}
    #

  • 相关阅读:
    兼容python3 小烦
    fstring 和 海象赋值
    Go-gRPC的简单使用
    GO-操作etcd简单示例
    进度报告
    进度报告
    windown 10 安装redis
    在.Net Core中使用T4工具生成实体文件
    python-with关键字,json,pickie序列化与反序列化
    python-文件操作-读,写,追加
  • 原文地址:https://www.cnblogs.com/gaobo543013306/p/9651839.html
Copyright © 2011-2022 走看看