重启Tomcat的脚本

说明:一台服务器上跑了8个Tomcat

case的方式:

#!/bin/bash
#reboot tomcat!!!
#Author:fansik
echo -e "\033[1;42;31mchoice tomcatNo reboot!!!\033[0m"
cat << EOF
        1:reboot tomcat8081
        2:reboot tomcat8082
        3:reboot tomcat8083
        4:reboot tomcat8084
        5:reboot tomcat8085
        6:reboot tomcat8086
        7:reboot tomcat8087
        8:reboot tomcat8088
EOF
read -t 10 -p "Enter a mnumber : " number
number=${number:-1}
case $number in
    1)
        proId=`ps -ef | grep tomcat8081 | grep java | awk ‘{print $2}‘`
        kill -9 $proId
        sleep 5
        cd /usr/tomcats/tomcat8081
        rm -rf logs/* work
        ./bin/startup.sh
        exit
        ;;
    2)
        proId=`ps -ef | grep tomcat8082 | grep java | awk ‘{print $2}‘`
        kill -9 $proId
        sleep 5
        cd /usr/tomcats/tomcat8082
        rm -rf logs/* work
        ./bin/startup.sh
        exit
        ;;
    3)
        proId=`ps -ef | grep tomcat8083 | grep java | awk ‘{print $2}‘`
        kill -9 $proId
        sleep 5
        cd /usr/tomcats/tomcat8083
        rm -rf logs/* work
        ./bin/startup.sh
        exit
        ;;
    4)
        proId=`ps -ef | grep tomcat8084 | grep java | awk ‘{print $2}‘`
        kill -9 $proId
        sleep 5
        cd /usr/tomcats/tomcat8084
        rm -rf logs/* work
        ./bin/startup.sh
        exit
        ;;
    5)
        proId=`ps -ef | grep tomcat8085 | grep java | awk ‘{print $2}‘`
        kill -9 $proId
        sleep 5
        cd /usr/tomcats/tomcat8085
        rm -rf logs/* work
        ./bin/startup.sh
        exit
        ;;
    6)
        proId=`ps -ef | grep tomcat8086 | grep java | awk ‘{print $2}‘`
        kill -9 $proId
        sleep 5
        cd /usr/tomcats/tomcat8086
        rm -rf logs/* work
        ./bin/startup.sh
        exit
        ;;
    7)
        proId=`ps -ef | grep tomcat8087 | grep java | awk ‘{print $2}‘`
        kill -9 $proId
        sleep 5
        cd /usr/tomcats/tomcat8087
        rm -rf logs/* work
        ./bin/startup.sh
        exit
        ;;
    8)
        proId=`ps -ef | grep tomcat8088 | grep java | awk ‘{print $2}‘`
        kill -9 $proId
        sleep 5
        cd /usr/tomcats/tomcat8088
        rm -rf logs/* work
        ./bin/startup.sh
        exit
        ;;
    *)
        echo "please input 1-8"
esac
时间: 2024-10-13 16:35:54

重启Tomcat的脚本的相关文章

用于部署war并重启Tomcat的脚本

只需要定义两个变量, 一个是目标tomcat实例的目录, 另一个是war包的名称 # Please define the absolute path of tomcat instance THIS_TC_INSTANCE='/home/tomcat/tomcat8_jdk8_1' THIS_APP_MODULE='throne-commons' df -h echo '' pid=`ps -ef|grep ${THIS_TC_INSTANCE}|grep -v 'grep'|grep 'java

sh 脚本重启tomcat

添加war 包 并重启tomcat的脚本 echo "stop tomcat..." ps -ef|grep root|grep "tomcat"|grep java|grep -v grep|awk '{print $2}'|xargs -i kill -9 {} sleep 6 echo "stop tomcat done!" #判断根目录下是否有XXXX.war,如果有的话,部署到services下 if [ -f XXXX.war ] t

一个根据内存使用情况重启tomcat的小脚本

有一台服务器上部署了tomcat,随着时间的推移,内存消耗越来越大,所以写了一个小脚本配合crontab定时检测内存,不足的情况下重启tomcat. #!/bin/bash #tomcat restart:out of memory LOG=./restart_tomcat.log TOMCAT=/tomcat/bin/ TOMCATDIR=/tomcat echo"----------------------------" >> $LOG mem_total=$(free

linux系统下重启tomcat的shell脚本

linux系统下重启tomcat的shell脚本: tomcat_home=/opt/apache-tomcat-6.0.32 #找到tomcat进程的id并kill掉 ps -ef |grep tomcat |awk {'print $2'} | sed -e "s/^/kill -9 /g" | sh - #删除日志文件,如果你不先删除可以不要下面一行 rm $tomcat_home/logs/* -rf #删除tomcat的临时目录 rm $tomcat_home/work/*

shell脚本中重启tomcat进程

shell脚本 #! /bin/bash SHUTDOWN="/root/tomcat/bin/shutdown.sh" STARTTOMCAT="/root/tomcat/bin/startup.sh" echo "关闭tomcat" $SHUTDOWN ps -ef |grep tomcat |grep /root/platform |grep -v 'grep'|awk '{print $2}' | xargs kill -9 sleep

linux Tomcat restart脚本简单版

linux系统下重启tomcat的shell脚本: tomcat_home=/opt/apache-tomcat-6.0.32  #找到tomcat进程的id并kill掉 ps -ef |grep tomcat |awk {'print $2'} | sed -e "s/^/kill -9 /g" | sh - #删除日志文件,如果你不先删除可以不要下面一行 rm $tomcat_home/logs/* -rf   #删除tomcat的临时目录 rm $tomcat_home/work

tomcat监控脚本(监控进程,测试接口,告警动作为发送邮件)

服务器环境:centos7.2 64位 tomcat8.5.6 tomcat 监控功能共需要两个脚本,如下: initMonitor.sh #!/bin/sh #初始化监控脚本相关变量 export tomcat_name=apache-tomcat-8.5.6 export tomcat_home=/usr/local/apache-tomcat-8.5.6 #测试接口访问地址 export webUrl=127.0.0.1:8080/yanglao/sysUserController/sys

通过端口查找对应的PID和路径,并重启tomcat

使用方法: 赋予可执行权限 ./tomcat_port_reboot.sh  tomcat端口 会根据端口查找PID和tomcat路径 默认不会重启 输入 y 则会重启tomcat 输入 n 则退出脚本 脚本内容如下: #!/bin/bash ##      通过端口查找对应的PID和路径,并重启tomcat  ## ## if [ ! -n "$1" ];then echo -e "Usage: $0 port1 port2 ...\n" exit 30 fi e

tomcat检测脚本

最近写了个简单的tomcat检测脚本.可以进行简单的进程和页面检测. #!/bin/bash # author:wangxingwei # date:2015/9/1 # fun:检测tomcat进程和页面是否正常 StartTomcat=/home/aspire/apps/tomcat/bin/startup.sh TomcatCache=/home/aspire/apps/tomcat/work TomcatCheckLog=/home/aspire/logs/check_tomcat_lo