Liunx中Tomcat的shutdown.sh无法杀死全部进程解决方案

刚开始时,我一直没有注意shutdown.sh,是无法杀掉tomcat进程的,因为我觉得是官方提供的脚本应该是没问题的了,直到有一天shutdown.sh之后无法使用startup.sh启动我使用ps -ef | grep tomcat 发现好几个之前shutdown的项目还在跑着,导致liunx内存耗尽无法启动更加多的项目了

解决办法修改bin目录下的catalina.sh和shutdown.sh
修改catalina.sh文件 添加一个if判断如果取不到PID获取bin目录下的pid

# Get standard environment variables
PRGDIR=`dirname "$PRG"`
if [ -z "$CATALINA_PID" ]; then
  CATALINA_PID=$PRGDIR/CATALINA_PID
  cat $CATALINA_PID
fi

修改shutdown.sh

#exec "$PRGDIR"/"$EXECUTABLE" stop "$@" 原来基础上加多-force
exec "$PRGDIR"/"$EXECUTABLE" stop -force "$@"

shutdown.sh 效果

[root@ bin]# ./shutdown.sh 
3398
Using CATALINA_BASE:   /data/eia
Using CATALINA_HOME:   /data/eia
Using CATALINA_TMPDIR: /data/eia/temp
Using JRE_HOME:        /usr/local/jdk
Using CLASSPATH:       /data/eia/bin/bootstrap.jar:/data/eia/bin/tomcat-juli.jar
Using CATALINA_PID:    /data/eia/bin/CATALINA_PID
Tomcat did not stop in time.
To aid diagnostics a thread dump has been written to standard out.
Killing Tomcat with the PID: 3398
The Tomcat process has been killed.

你可能感兴趣的:(日常踩坑)