Skip to content

Instantly share code, notes, and snippets.

@jatin33
Last active June 1, 2020 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jatin33/0fb1d36eb8b4f0657c74bcaf1d0bc17d to your computer and use it in GitHub Desktop.
Save jatin33/0fb1d36eb8b4f0657c74bcaf1d0bc17d to your computer and use it in GitHub Desktop.
#!/bin/bash
echo Enter port number to kill
read port_number
pid="$(lsof -i:$port_number | awk '{ print $2 }' | sed -n 2p)"
kill -9 $pid
echo $?
@jatin33
Copy link
Author

jatin33 commented Dec 7, 2019

How to run it?
./killProcessOnPort.sh
Terminal will ask you the port number to kill.

@sladyn98
Copy link

sladyn98 commented Jun 1, 2020

Needed this :) Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment