Created
April 22, 2020 07:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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