How can I kill TCP port 16969 in Bash?

后端 未结 4 912
小鲜肉
小鲜肉 2021-02-01 08:00

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

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-01 09:03

    I think that:

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

    Should do the trick.

    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
    

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

提交回复
热议问题