Skip to content

Instantly share code, notes, and snippets.

@srt32
Created April 29, 2019 16:58
Show Gist options
  • Save srt32/69770795c9baae0a0f12b2196ecddef1 to your computer and use it in GitHub Desktop.
Save srt32/69770795c9baae0a0f12b2196ecddef1 to your computer and use it in GitHub Desktop.
`killportprocs 3000` - will print and then kill all the pids bound to port 3000
killportprocs() {
local targetport=${1:?pass in target port}
local pids=$(lsof -i :$targetport | awk '{print $2}' | tail +2)
echo "$pids"
echo $pids | xargs kill -9
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment