Skip to content

Instantly share code, notes, and snippets.

@psheraton
Last active August 17, 2018 20:11
Show Gist options
  • Save psheraton/decde96fbac916197509c8db9e6c2a47 to your computer and use it in GitHub Desktop.
Save psheraton/decde96fbac916197509c8db9e6c2a47 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