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

Posted jonban

tags:

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

 

1.   启动

#!/bin/bash

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

if test -z $pids
then
    bash /root/soft/tomcat/bin/startup.sh
    echo -e "Start Finished!
"
else
   echo -e "tomcat has already started!
"
fi

 

 

2.  停止

#!/bin/bash

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

for pid in ${pids}
do
    kill -9 ${pid}
done

echo -e "Stop Finished!
"

 

 

3.  重启

#!/bin/bash

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

for pid in ${pids}
do
    kill -9 ${pid}
done

# start
bash /root/soft/tomcat/bin/startup.sh

echo -e "Restart Finished!
"

 

 

 

.

以上是关于Linux 启动停止重启tomcat工具(Shell脚本)的主要内容,如果未能解决你的问题,请参考以下文章

Linux下Tomcat启动,停止命令

为Tomcat添加启动停止重启

supervisor 安装配置实战

服务器重启,停止后再启动

tomcat服务器启动后有停止了.........

centos7中使用yum安装tomcat以及它的启动停止重启