Windows 环境中
1. 开始---->运行---->cmd,或者是window+R组合键,调出命令窗口
2. netstat -ano | findstr 端口号
C:\Users\Administrator>netstat -ano | findstr 18388
TCP 0.0.0.0:18388 0.0.0.0:0 LISTENING 1984
UDP 0.0.0.0:18388 *:* 1984
3. tasklist|findstr PID
,查看是哪个进程或者
C:\Users\Administrator>tasklist|findstr 1984
node.exe 1984 2 26,024 K
4. taskkill /f /t /pid PID
结束进程
C:\Users\Administrator>taskkill /f /t /pid 1984
成功: 已终止 PID 1984 (属于 PID 2916 子进程)的进程。
Linux 环境中
1. netstat -ano | grep 端口号
[root@guoke3915 ~]# netstat -anp | grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1370/nginx: master
后面1370就是端口号,nginx:master是进程名
2. ps -ef | grep PID 查看进程详情
[root@guoke3915 ~]# ps -ef | grep 1370
root 1370 1 0 Feb09 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 1373 1370 0 Feb09 ? 00:00:00 nginx: worker process
root 20707 20681 0 17:41 pts/0 00:00:00 grep --color=auto 1370
3. kill -9 PID 结束进程
kill -9 1370