简体   繁体   English

杀死运行在任何端口上的 tomcat 服务,Windows

[英]Kill tomcat service running on any port, Windows

杀死运行在任何端口上的 tomcat 服务,Windows 使用像 8080/8005 这样的命令提示符

1) Go to (Open) Command Prompt (Press Window + R then type cmd Run this). 1)转到(打开)命令提示符(按Window + R然后键入cmd Run this)。

2) Run following commands 2)运行以下命令

For all listening ports对于所有监听端口

netstat -aon | netstat -aon | find /i "listening"找到 /i “听”

Apply port filter应用端口过滤器

netstat -aon |find /i "listening" |find "8080" netstat -aon |find /i "listening" |find "8080"

Finally with the PID we can run the following command to kill the process最后使用PID,我们可以运行以下命令来终止进程

3) Copy PID from result set 3)从结果集中复制PID

taskkill /F /PID taskkill /F /PID

Ex: taskkill /F /PID 189例如:taskkill /F /PID 189

Sometimes you need to run Command Prompt with Administrator privileges有时您需要以管理员权限运行命令提示符

Done !!!完毕 !!! you can start your service now.你现在可以开始你的服务了。

netstat -ano | findstr :3010

在此处输入图片说明

taskkill /F /PID

在此处输入图片说明

But it won't work for me但这对我不起作用

then I tried taskkill -PID <processorid> -F然后我尝试了taskkill -PID <processorid> -F

Example:- taskkill -PID 33192 -F Here 33192 is the processorid and it works示例:- taskkill -PID 33192 -F这里 33192 是处理器 ID,它可以工作在此处输入图片说明

Based on all the info on the post, I created a little script to make the whole process easy.根据帖子中的所有信息,我创建了一个小脚本来简化整个过程。

@ECHO OFF
netstat -aon |find /i "listening"

SET killport=
SET /P killport=Enter port: 
IF "%killport%"=="" GOTO Kill

netstat -aon |find /i "listening" | find "%killport%"

:Kill
SET killpid=
SET /P killpid=Enter PID to kill: 
IF "%killpid%"=="" GOTO Error

ECHO Killing %killpid%!
taskkill /F /PID %killpid%

GOTO End
:Error
ECHO Nothing to kill! Bye bye!!
:End

pause

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM