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?
Use the kill command in combination with the lsof (list of open files) command to kill process listening to a particular port. As described in a previous post, the lsof command helps us identify which process is listening to a particular port - Just pass the result of the lsof command to the kill command.
Open a CMD window in Administrator mode by navigating to Start > Run > type cmd > right-click Command Prompt, then select Run as administrator. Use the netstat command lists all the active ports. To kill this process (the /f is force): taskkill /pid 18264 /f.
You can use $():
kill $(lsof -t -i:port)
You can use
kill -9 `lsof -t -i:port`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With