Skip to content

Instantly share code, notes, and snippets.

@shaharke
Created March 14, 2014 09:49
Show Gist options
  • Save shaharke/9544965 to your computer and use it in GitHub Desktop.
Save shaharke/9544965 to your computer and use it in GitHub Desktop.
Kill by port
#! /bin/bash
PORT=$1
if [[ -z "$PORT" ]]; then
echo "Usage: killp <port>"
exit 1
fi
PID=`lsof -i :$PORT -t`
if [[ -n "$PID" ]]; then
echo "Killing process listening on $PORT"
kill -9 $PID
else
echo "No process listeing on $PORT"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment