Skip to content

Instantly share code, notes, and snippets.

@olivierrr
Last active August 29, 2015 14:17
Show Gist options
  • Save olivierrr/5115e6a1c47bc383242c to your computer and use it in GitHub Desktop.
Save olivierrr/5115e6a1c47bc383242c to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 <PORT>";
return 1;
fi
PID=$(lsof -i :$1 | tr -s ' ' | cut -d ' ' -f 2 | sed -n 2p)
if [ -z "$PID" ]; then
echo "Can't find Process in that port";
return 1;
else
kill -9 $PID;
echo "Done!";
return 0;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment