Skip to content

Instantly share code, notes, and snippets.

@coolgo
Forked from snow-swallow/killps.sh
Created February 6, 2013 10:32
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 coolgo/4721766 to your computer and use it in GitHub Desktop.
Save coolgo/4721766 to your computer and use it in GitHub Desktop.
#! /bin/sh
lsof -n -i4TCP:$1 | grep LISTEN
pid=`lsof -n -i4TCP:$1 | grep LISTEN | awk '{print $2}'`
if [ $pid ]
then
kill -9 $pid
echo "[`date "+%Y-%m-%d %H:%M:%S"`] Process kill successfull!"
else
echo "[`date "+%Y-%m-%d %H:%M:%S"`] No process exists on port $1."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment