近期在启用网站的时候,出现启动失败,此时想到在dos下使用netstat来查看80端口被什么程序占用了,很多时候我们都需使用netstat来查询,现简单介绍使用方法
查看端口占用
在windows命令行窗口下执行:运行--cmd
C:\>netstat -aon|findstr "80"
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 10.52.32.119:58342 1.192.193.45:80 ESTABLISHED 3100
TCP 10.52.32.119:60504 59.37.96.250:80 ESTABLISHED 2000
TCP 10.52.32.119:60916 180.163.25.114:443 CLOSE_WAIT 7940
TCP 10.52.32.119:62793 182.140.185.140:80 CLOSE_WAIT 7940
TCP 10.52.32.119:62883 183.3.235.188:8080 ESTABLISHED 6760
端口被进程号为4的进程占用,继续执行下面命令:
C:\>tasklist|findstr "4"
thread.exe 2016 Console 0 16,064 K
关闭进程
/pid 后面是系统的进程id 如先查到notepad.exe的id是2152,则格式为 taskkill /pid 2152
多个时格式为 taskkill /pid 2152 /pid 1284
/im 后面是系统的进程名 如要关闭notepad.exe,格式为taskkill /im notepad.exe,指定多个 时格式为taskkill /im notepad.exe /im iexplorer.exe .如果是要关闭所有的,则使用通配符*,即 askkill /im *.exe
/T 后面是结合上两个命令实现,如taskkill /t /im notepad.exe或者taskkill /t /pid 2152 这个效果是提示后在使用者确定后关闭,有提示框.
/F 后面也是结合/pid 和/im实现,如taskkill /F /im notepad.exe或者taskkill /F /pid 2152