Last active
August 17, 2018 20:11
-
-
Save psheraton/decde96fbac916197509c8db9e6c2a47 to your computer and use it in GitHub Desktop.
Kill on Port (OSX)
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 | |
# Kill a process that is listening on a port | |
PORT=$1 | |
PID=$(lsof -i tcp:$PORT | grep LISTEN |tr -s ' ' | cut -d ' ' -f 2) | |
if [ $PID ]; then | |
kill $PID | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment