Skip to content

Instantly share code, notes, and snippets.

@dasegn
Created December 28, 2016 06:31
Show Gist options
  • Save dasegn/e306d681bb6fa8eddbf1586f909b094f to your computer and use it in GitHub Desktop.
Save dasegn/e306d681bb6fa8eddbf1586f909b094f to your computer and use it in GitHub Desktop.
Terminate programs by port via bash in Mac (via: https://blog.adriaan.io/mac-terminate-program-by-port.html)
# terminate function
terminate () {
lsof -i "tcp:$1" | tail -1 | awk '{print $2}' | xargs kill -9 && echo "Killed proces on port $1" || echo "Failed to kill proces on port $1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment