Last active
July 15, 2016 07:31
-
-
Save barseghyanartur/2d154e1a8b0e648f065310ac2478cbdb to your computer and use it in GitHub Desktop.
Kill Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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