本文介绍了如何在Bash中杀死TCP端口16969?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用TCP端口16969的应用程序.有时它需要快速动态重启软件内核.但是,如果我启动得太快,我就会被锁定

I have an application which uses TCP port 16969. It sometimes requires a quick software kernel reboot on the fly. But if I launch it too fast, I am locked with

所以我想触发我的Bash脚本,该脚本可以使用16969杀死所有正在运行或监听的端口,但是我该怎么做?

So I want to trigger my Bash script which can kill any running or listening port with 16969, but how can I do that?

$ lsof -w -n -i tcp:16969 # this gives me a list of 50 lines but how can I kill them all?

推荐答案

我认为:

lsof -i tcp:22 | grep LISTEN | awk '{print $2}' | xargs kill

应该做到这一点.

要在松散之前仔细检查它想运行什么命令,请在 kill 之前添加 echo ,如下所示:

To double check what commands it wants to run before letting it loose add an echo before the kill like this:

lsof -i tcp:22 | grep LISTEN | awk '{print $2}' | xargs echo kill

然后它将列出通常会杀死的PID

It'll then list the PIDs that it would ordinarily kill

这篇关于如何在Bash中杀死TCP端口16969?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 01:21