Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

linux - 如何终止在Linux中特定端口上运行的进程?(How to kill a process running on particular port in Linux?)

I tried to close the tomcat using ./shutdown.sh from tomcat /bin directory.

(我试图使用tomcat /bin目录中的./shutdown.sh关闭tomcat。)

But found that the server was not closed properly.

(但是发现服务器没有正确关闭。)

And thus I was unable to restart

(因此我无法重新启动)
My tomcat is running on port 8080 .

(我的tomcat在端口8080上运行。)

I want to kill the tomcat process running on 8080 .

(我想杀死运行在8080上的tomcat进程。)

I first want to have the list of processes running on a specific port (8080) in order to select which process to kill.

(我首先要具有在特定端口(8080)上运行的进程的列表,以便选择要杀死的进程。)

  ask by veer7 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This fuser 8080/tcp will print you PID of process bound on that port.

(此fuser 8080/tcp将为您打印该端口上绑定的进程的PID。)

And this fuser -k 8080/tcp will kill that process.

(而这个fuser -k 8080/tcp将终止该进程。)

Works on Linux only.

(仅适用于Linux。)

More universal is use of lsof -i4 (or 6 for IPv6).

(更通用的是使用lsof -i4 (对于IPv6, lsof -i4 6)。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...