Last active
May 10, 2018 10:21
-
-
Save fewstera/0500e5c041420f55577d6b5a9c8d486c to your computer and use it in GitHub Desktop.
Shell function to kill process running on port
This file contains hidden or 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
# Taken from https://github.com/kevinSuttle/dotfiles/commit/9458141f40094d96952adc7c423cbdddeb909a81#diff-0eaa46c12c8190dcb4e4b46838220683 | |
# Usage: `kill-port 8080` to kill the process running on port 8080 | |
kill-port() { | |
if [ -z "$1" ]; then | |
echo "Usage: kill-port [port number]" >&2 | |
return 1 | |
fi | |
lsof -i TCP:$1 | awk '/LISTEN/{print $2}' | xargs kill -9 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment