Created
January 15, 2013 15:53
-
-
Save ncherro/4539635 to your computer and use it in GitHub Desktop.
Kill a process on a port. Defaults to 3000 (Rails)
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
killport() { | |
if [ -n "${1}" ]; then | |
port=$1 | |
else | |
# default (Rails-centric) | |
port="3000" | |
fi | |
pid=`lsof -wni tcp:$port | awk 'NR==2 { print $2 }'` | |
if [ -n "${pid}" ]; then | |
kill -9 $pid | |
echo "Killed process $pid" | |
else | |
echo "No processes were found listening on tcp:$port" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment