How can I kill TCP port 16969 in Bash?

后端 未结 4 836
小鲜肉
小鲜肉 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 08:45

    I often get this problem using JBoss in Netbeans...

    My solution :

    In a terminal type :

     sudo netstat -lnp | grep 8080  
    

    Then it display something like:

     tcp6       0      0 :::8080       :::*        LISTEN      1722/java
    

    Then use:

     kill 1722  //replace 1722 by the PID you found.
    

    Hope it will help!

    0 讨论(0)
  • 2021-02-01 08:58

    Have you tried using tcpkill?

    example:

    tcpkill -i eth0 port 21
    
    0 讨论(0)
  • 2021-02-01 08:58
    fuser -k 16969/tcp 
    

    can free that port. This is a useful command that can be used to close ports, whichever it is.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题