Created
November 1, 2017 16:03
-
-
Save cjroth/1e224baead07389ab7e712fa57bb7179 to your computer and use it in GitHub Desktop.
Shortcut command to kill a process by port: die <port>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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