Skip to content

Instantly share code, notes, and snippets.

@mkows
Last active October 13, 2020 11:01
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 mkows/1c1250bd21a7ba9ecfaf3bb79f9b3493 to your computer and use it in GitHub Desktop.
Save mkows/1c1250bd21a7ba9ecfaf3bb79f9b3493 to your computer and use it in GitHub Desktop.
Kill process on port (8080)
PROCESS_PHRASE="*:8080 (LISTEN)"
PROCESS_LINE=`lsof -Pn | grep "$PROCESS_PHRASE"`
if [[ -n $PROCESS_LINE ]]; then
PROCESS_ID=`awk '{print $2}' <<< $PROCESS_LINE`
echo "Killing process id=$PROCESS_ID ('$PROCESS_LINE')"
else
echo "No matching process found for '$PROCESS_PHRASE'"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment