使用shutdown.sh无法将tomcat停止解决

Apache-tomcat官方 shutdown是通过AJP指令停止服务,需要操作系统root授权,与国网等机构的安全评测冲突,因此采样其他方式来停止tomcat。
我的方法是编写一个shell脚本stop.sh ,放在tomcat的bin目录,例如:/home/smart/apache-tomcat-8.5.42/bin,赋执行权限

smart@linx:~$  chmod +x stop.sh

当需要停止当前目录下的tomcat时,执行

smart@linx:~$  sh /home/smart/apache-tomcat-8.5.42/bin/stop.sh

或者在对应目录中执行

smart@linx:~$  ./stop.sh

以下是stop.sh脚本的内容

#!/bin/sh
echo "开始关闭当前目录下启动的Tomcat"
TOM_HOME=$(cd `dirname $0`;cd ..;pwd)
echo "停止命令执行前的进程列表"
ps -ef|grep $TOM_HOME|grep -v grep|grep -v kill
if [ $? -eq 0 ];then
	kill -9 `ps -ef|grep $TOM_HOME|grep -v grep|grep -v kill|awk '{print $2}'`
else
	echo $TOM_HOME' 目录下没有启动Tomcat进程'
fi
echo "停止命令执行后的进程列表"
ps -ef|grep $TOM_HOME|grep -v grep

猜你喜欢

转载自blog.csdn.net/BUG_88/article/details/105658297