Skip to content

Instantly share code, notes, and snippets.

@YasienDwieb
Last active February 23, 2020 10:13
Show Gist options
  • Save YasienDwieb/df61a0b53093cbd103f638a48bfb3e54 to your computer and use it in GitHub Desktop.
Save YasienDwieb/df61a0b53093cbd103f638a48bfb3e54 to your computer and use it in GitHub Desktop.
Solves port already in use issue by killing processes that use that port
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage: $0 <port>"
exit
fi
for i in `sudo lsof -i :8080| sed 's/\( \)*/\1/g' | cut -d" " -f2| sort | uniq| egrep -o '[0-9]*'`;do
sudo kill -9 $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment