Nice! ❤️
I've modified it a bit, so we don't need to write into a temp-file.
#!/bin/bash
pid=$(lsof -n -i :"$1" | tail -1 | awk '{print $2}')
if [[ -n $pid ]]
then
kill -9 "$pid" && echo "Process which blocked port $1 was killed" || echo "Could not kill process blocking port $1..."
else
echo "Seems like no process is blocking port $1"
fi
Also, we might need to use sudo for both lsof and kill if we do not own the process. But for the local dev environment it should be just fine like this.
Nice! ❤️
I've modified it a bit, so we don't need to write into a temp-file.
Also, we might need to use sudo for both lsof and kill if we do not own the process. But for the local dev environment it should be just fine like this.
Thanks again!
Great, that's even cleaner !