我尝试在tomcat /bin目录下使用。/shutdown.sh关闭tomcat。但发现服务器没有正确关闭。因此我无法重新启动我的tomcat运行在端口8080上。

我想终止在8080上运行的tomcat进程。我首先想要在特定端口(8080)上运行的进程列表,以便选择要终止哪个进程。


当前回答

这将杀死端口80上运行的程序

sudo fuser -k 80/tcp

其他回答

杀死特定端口上所有进程的最佳方法;

kill -9 $(sudo lsof -t -i:8080)

Linux:如果你知道端口,你可以使用这个命令:

netstat -plten | grep LISTEN | grep 8080

AIX:

netstat -Aan | grep LISTEN | grep 8080

然后使用第一列(例如:f100050000b05bb8)并运行以下命令:

rmsock f100050000b05bb8 tcpcb

杀死进程。

执行如下命令,查询到8080端口号PID:

Sudo lsof -t -i:8080

你现在可以使用以下命令轻松地杀死你的PID:

须藤杀-9

您可以使用一个命令来杀死特定端口上的进程,使用以下命令:

Sudo kill -9 $(Sudo lsof -t:8000)

Git Bash的其他方式:

stopProcessByPortNumber() {
port=":${1}"
portStrLine="$(netstat -ano | findstr LISTENING | findstr $port)"
processId="$(grep -oP '(\d+)(?!.*\d)' <<< $portStrLine)"
echo $processId
taskkill -PID $processId -F
}
sudo apt-get install psmisc (or sudo yum install psmisc)
sudo fuser 80/tcp

结果: 80/tcp: 1858 1867 1868 1869 1871

逐个杀死进程

杀死-9 1858