Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tmanOC
Created April 22, 2020 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmanOC/76e643cb742338d94120e7d8cceb312a to your computer and use it in GitHub Desktop.
Save tmanOC/76e643cb742338d94120e7d8cceb312a to your computer and use it in GitHub Desktop.
Script that works on mac for killing scripts that use a certain port
lsof -i:$1 | awk '{print $2}' | grep -v -e "PID" | sort -u > temp.txt
pids=`cat temp.txt`
rm temp.txt
echo "The ids: $pids"
for id in $pids; do
echo "killing $id";
kill -9 $id;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment