导航

判断某个端口被那个进程占用

Posted on 2016-08-31 12:13  蝈蝈俊  阅读(615)  评论(0编辑  收藏  举报

 

Windows下

找到占用端口的PID

使用 netstat –aon 返回的最后一项是占用该端口的 PID。

image

我们再加上 findstr 查询指定端口, 就可以过滤掉其他的端口

netstat –aon | findstr “8086”

image

 

通过 pid 找到 进程信息

tasklist 返回当前进程的信息:

image

tasklist | findstr  “5316”

image

tasklist -fi "pid eq 2860" –v   列出pid是2860的这个进程的详细信息

 

更详细的进程信息可以用下面命令:

wmic process where processid="5316" get name,executablepath,processid,CommandLine

image

 

参考:

http://coltiam.blog.51cto.com/1364465/394060

http://www.cnblogs.com/xyzdw/articles/2108149.html 

 

终止进程:

   >taskkill /pid 1688 /F
成功: 已终止 PID 为 1688 的进程。

Linux 下则是用下面命令:

 

查询端口是否被占用,被哪个进程占用有两种方式:

  • 1、netstat -anl | grep "80" ;
  • 2、lsof -i:80

终止进程的方式:kill pid