Created
March 14, 2014 09:49
-
-
Save shaharke/9544965 to your computer and use it in GitHub Desktop.
Kill by 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
#! /bin/bash | |
PORT=$1 | |
if [[ -z "$PORT" ]]; then | |
echo "Usage: killp <port>" | |
exit 1 | |
fi | |
PID=`lsof -i :$PORT -t` | |
if [[ -n "$PID" ]]; then | |
echo "Killing process listening on $PORT" | |
kill -9 $PID | |
else | |
echo "No process listeing on $PORT" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment