我尝试在tomcat /bin目录下使用。/shutdown.sh关闭tomcat。但发现服务器没有正确关闭。因此我无法重新启动我的tomcat运行在端口8080上。
我想终止在8080上运行的tomcat进程。我首先想要在特定端口(8080)上运行的进程列表,以便选择要终止哪个进程。
我尝试在tomcat /bin目录下使用。/shutdown.sh关闭tomcat。但发现服务器没有正确关闭。因此我无法重新启动我的tomcat运行在端口8080上。
我想终止在8080上运行的tomcat进程。我首先想要在特定端口(8080)上运行的进程列表,以便选择要终止哪个进程。
当前回答
选择端口号并应用netstat命令中的grep,如下所示
netstat -ap | grep :7070
控制台输出
tcp 0 0:::7070:::* LISTEN 3332/java
根据PID(进程标识号)终止服务
kill -9 3332
其他回答
这是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
sudo apt-get install psmisc (or sudo yum install psmisc)
sudo fuser 80/tcp
结果: 80/tcp: 1858 1867 1868 1869 1871
逐个杀死进程
杀死-9 1858
在我的情况下,cent os在建议的答案中有一些问题。所以我使用了以下解决方案:
ss -tanp | grep 65432 | head -1 | grep -Po "(?<=pid=).*(?=,)" | xargs kill
列出监听端口8080的所有进程:
lsof -i:8080
杀死任何监听8080端口的进程:
kill $(lsof -t -i:8080)
或者更激烈:
kill -9 $(lsof -t -i:8080)
(-9对应SIGKILL -立即终止/硬杀信号:参见kill信号列表和kill命令中-9选项的用途是什么?如果没有指定要终止的信号,则发送TERM信号,即-15或软终止,这有时不足以终止进程。
Linux:如果你知道端口,你可以使用这个命令:
netstat -plten | grep LISTEN | grep 8080
AIX:
netstat -Aan | grep LISTEN | grep 8080
然后使用第一列(例如:f100050000b05bb8)并运行以下命令:
rmsock f100050000b05bb8 tcpcb
杀死进程。