IT常识
技术 Python PHP JavaScript IOS Android Java 数据库 资源 公众号 代码片段 github
  • IT常识
  • web服务器

Shell重启Tomcat脚本

Posted 2021-01-08 tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shell重启Tomcat脚本相关的知识,希望对你有一定的参考价值。

 

#!/bin/bash

echo -e "


"

#force kill flag,if equal [f] to force kill all
flag="HelloShell"
if test $# -gt 0
then
    flag=$1
fi

pids=`ps -ef|grep tomcat | grep -v "grep" | awk ‘{print $2}‘`
#pids=`ps -ef|grep -w tomcat | grep -v "grep" | awk ‘{print $2}‘`

count=0
pid_num=0
for pid in ${pids}
do
    pid_num=${pid}
    count=`expr ${count} + 1`
done

if test $[count] -gt 1
then
    if test $flag = "f"
    then
        for pid in ${pids}
        do
            echo "kill " ${pid}
            kill -9 ${pid}
        done
        echo "Force kill more progress success!"
    else
        echo "Exist more progress is running, Input param [f] to force kill."
    fi
else
    if test $[count] -eq 1
    then
        kill -9 ${pid_num}
        echo "Kill " ${pid_num} " Success!"
    else
        echo "Clear!"
    fi
fi

# start
bash /root/soft/apache-tomcat-7.0.90/bin/startup.sh



echo -e "


"

 

以上是关于Shell重启Tomcat脚本的主要内容,如果未能解决你的问题,请参考以下文章

shell----重启tomcat问题

Shell重启Tomcat脚本

shell脚本监控Tomcat并重启发送短信

Linux 启动停止重启tomcat工具(Shell脚本)

Linux下shell脚本监控Tomcat的状态并实现自动启动

小工具shell检测进程状态异常自动重启

(c)2006-2024 SYSTEM All Rights Reserved IT常识