How to combine “lsof -i :port” and “kill pid” in bash

丶灬走出姿态 提交于 2019-12-04 03:40:02

问题


How do i combine these two commands in the bash:

lsof -i :port
kill pid

The first one returns the PID i want to kill to release the port. The second one kills the returned PID.

I am doing this because I don´t know of any way to kill a jetty webserver within the Netbeans IDE on OSX. Is there a way?


回答1:


You can use $():

kill $(lsof -t -i:port)



回答2:


You can use

kill -9 `lsof -t -i:port`


来源:https://stackoverflow.com/questions/33101725/how-to-combine-lsof-i-port-and-kill-pid-in-bash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!