Skip to content

Instantly share code, notes, and snippets.

@cjroth
Created November 1, 2017 16:03
Show Gist options
  • Save cjroth/1e224baead07389ab7e712fa57bb7179 to your computer and use it in GitHub Desktop.
Save cjroth/1e224baead07389ab7e712fa57bb7179 to your computer and use it in GitHub Desktop.
Shortcut command to kill a process by port: die <port>
function _die() {
local PID="$(lsof -t -i:$1 -sTCP:LISTEN)"
if [[ -z "$PID" ]]; then
echo >&2 "No process is listening on port $1"
return 2
fi
echo >&2 "You killed it!"
kill -9 "$PID"
}
alias die='_die'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment