Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To sta

时间:2022-05-20 16:45:02

1 错误描述

Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use.

The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).

 

2 错误原因

    Tomcat进程端口在使用中

 

3 解决办法

   关闭Tomcat进程

如何强制关闭Tomcat,同时杀死进程

  
一般的,我们都是使用 ps aux | grep "tomcat",找到相应的进程id,然后用kill -9 id来强制关闭进程, 但是使用这样每次都要去做一趟这样的操作,实在是繁琐哇! 于是,我们可以在shutdown.sh中编写杀死进程的代码,就可以了啊。
 
======修改============bin/shutdown.sh  
exec "$PRGDIR"/"$EXECUTABLE" stop -force "$@"  加上 -force  
  
======修改====================bin/catalina.sh  
在PRGDIR=`dirname "$PRG"`后面加上
if [ -z "$CATALINA_PID" ]; then
     CATALINA_PID=$PRGDIR/CATALINA_PID
     cat $CATALINA_PID
fi