美文网首页
shell 杀死指定端口的进程

shell 杀死指定端口的进程

作者: Josaber | 来源:发表于2017-10-10 10:27 被阅读0次

    查询所在端口进程

    $ netstat -nlp | grep :8080 | awk '{print $7}' | awk -F"/" '{ print $1 }'
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    1817
    

    杀死指定ID进程

    $ kill -9 1817
    

    杀死指定端口进程

    $ kill -9 $(netstat -nlp | grep :8080 | awk '{print $7}' | awk -F"/" '{ print $1 }')
    (Not all processes could be identified, non-owned process info
     will not be shown, you would have to be root to see it all.)
    

    PS:
    测试环境:Ubuntu 14.04.5 LTS

    相关文章

      网友评论

          本文标题:shell 杀死指定端口的进程

          本文链接:https://www.haomeiwen.com/subject/hffvyxtx.html