我尝试在tomcat /bin目录下使用。/shutdown.sh关闭tomcat。但发现服务器没有正确关闭。因此我无法重新启动我的tomcat运行在端口8080上。
我想终止在8080上运行的tomcat进程。我首先想要在特定端口(8080)上运行的进程列表,以便选择要终止哪个进程。
我尝试在tomcat /bin目录下使用。/shutdown.sh关闭tomcat。但发现服务器没有正确关闭。因此我无法重新启动我的tomcat运行在端口8080上。
我想终止在8080上运行的tomcat进程。我首先想要在特定端口(8080)上运行的进程列表,以便选择要终止哪个进程。
当前回答
像这样试试,
sudo fuser -n tcp -k 8080
其他回答
简单地运行这个命令。别忘了用你的端口替换端口号;)
kill -9 $(sudo lsof -t -i:portnumber)
Linux:首先,如果你知道端口,你可以找到这个命令的PID:
netstat -tulpn
例子:-
Local Address Foreign Address State PID/Program name
:::3000 :::* LISTEN 15986/node
然后进行终止过程。执行如下命令:
kill -9 PID
Expample: -
杀死-9 15986
使用命令
sudo netstat -plten |grep java
使用grep Java作为tomcat使用Java作为他们的进程。
它将显示带有端口号和进程id的进程列表
tcp6 0 0 :::8080 :::* LISTEN
1000 30070621 16085/java
“/java”前面的数字是进程号。现在使用kill命令终止进程
kill -9 16085
-9表示进程将被强制终止。
这是Windows的解决方案:
C:\Users\Niroshan>netstat -ano|findstr "PID :8080"
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 18264
taskkill /pid 18264 /f
杀死特定端口上所有进程的最佳方法;
kill -9 $(sudo lsof -t -i:8080)