一条命令根据端口杀死进程windows和linux

以你之姓@ 2022-11-29 12:54 212阅读 0赞

windows

  1. netstat -ano | grep 8080

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3RhbmdodWFuMDgyNw_size_16_color_FFFFFF_t_70

  1. taskkill /pid 1032 -f

或者(批量杀死,主要是findstr,先查找,可以先 netstat -ano 看一下)

  1. netstat -ano | findstr /c:"0.0.0.0:80 "|awk -F" " '{print $5}'|xargs taskkill -f -PID

80后面有空格

/c:后面没有空格

findstr是根据正则表达式查找,需要查找包含空格的文字,否则容易查询8001这种两个的端口

linux

  1. ps -ef | grep pidname | grep -v grep | awk '{print $2}' | xargs kill -9

或者

  1. pkill -9 redis

参考博客:

findstr https://blog.csdn.net/playboy1/article/details/6869384

netstat windows下杀死进程 https://jingyan.baidu.com/article/7f41ecec496df8593d095cf3.html

发表评论

表情:
评论列表 (有 0 条评论,212人围观)

还没有评论,来说两句吧...

相关阅读