Skip to content

Instantly share code, notes, and snippets.

@GuhaAG
Created August 25, 2020 07:50
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 GuhaAG/32ae5f04293e9075e44754785b41f8b9 to your computer and use it in GitHub Desktop.
Save GuhaAG/32ae5f04293e9075e44754785b41f8b9 to your computer and use it in GitHub Desktop.
stop process at port
#!/bin/bash
touch temp.text
lsof -n -i4TCP:$1 | awk '{print $2}' > temp.text
pidToStop=`(sed '2q;d' temp.text)`
> temp.text
if [[ -n $pidToStop ]]
then
kill -9 $pidToStop
echo "!! $1 is stopped !!"
else
echo "Sorry nothing running on above port"
fi
rm temp.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment