Skip to content

Instantly share code, notes, and snippets.

@barseghyanartur
Last active July 15, 2016 07:31
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 barseghyanartur/2d154e1a8b0e648f065310ac2478cbdb to your computer and use it in GitHub Desktop.
Save barseghyanartur/2d154e1a8b0e648f065310ac2478cbdb to your computer and use it in GitHub Desktop.
Kill Django
# -*- mode: shell-script -*-
function kill_django {
# Assuming that Django runs on port 8000, we find
# the process with netstat and kill it.
DJANGO_PORT=':8000'
DJANGO_INFO=$(sudo netstat -ntlp | cat | grep $DJANGO_PORT)
#echo $DJANGO_INFO
DJANGO_PID_PROC=$(echo $DJANGO_INFO | cut -d ' ' -f 7-)
#echo $DJANGO_PID_PROC
DJANGO_PID=$(echo $DJANGO_PID_PROC | cut -d '/' -f -1)
#echo $DJANGO_PID
if
test -n "$DJANGO_PID"
then
sudo kill $DJANGO_PID
echo "killed $DJANGO_PID_PROC"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment