我尝试在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
其他回答
这将杀死端口80上运行的程序
sudo fuser -k 80/tcp
列出监听端口8080的所有进程:
lsof -i:8080
杀死任何监听8080端口的进程:
kill $(lsof -t -i:8080)
或者更激烈:
kill -9 $(lsof -t -i:8080)
(-9对应SIGKILL -立即终止/硬杀信号:参见kill信号列表和kill命令中-9选项的用途是什么?如果没有指定要终止的信号,则发送TERM信号,即-15或软终止,这有时不足以终止进程。
这是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
要知道某个端口上运行的服务的pid:
netstat -tulnap | grep :*port_num*
您将得到该过程的描述。现在使用kill或kill -9 pid。容易死亡。
e.g
Netstat -ap | grep:8080
tcp6 0 0 :::8080 :::* LISTEN 1880/java
Now:
kill -9 1880
记住以root用户运行所有命令
kill -9 ' fuser 8080/tcp|xargs -n 1 ',该命令同时关闭监听8080端口的tcp连接进程