Skip to content

Instantly share code, notes, and snippets.

@etuchscherer
Forked from psheraton/kop.sh
Created August 17, 2018 20:11
Show Gist options
  • Save etuchscherer/636f2a6d9787a82a3baea8d39e8e2cab to your computer and use it in GitHub Desktop.
Save etuchscherer/636f2a6d9787a82a3baea8d39e8e2cab to your computer and use it in GitHub Desktop.
Kill on Port (OSX)
#!/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