-
-
Save etuchscherer/636f2a6d9787a82a3baea8d39e8e2cab 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