Skip to content

Instantly share code, notes, and snippets.

@wxianfeng
Created July 11, 2011 07:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save wxianfeng/1075411 to your computer and use it in GitHub Desktop.
Save wxianfeng/1075411 to your computer and use it in GitHub Desktop.
manage python SimpleHTTPServer for serve page
#!/bin/bash
##
# start|stop|restart python SimpleHTTPServer
#
# TODO:
# use shell Function for DRY
# USAGE:
# ./manage_simplehttpserver.sh start|stop|restart
#
# VIEW:
# http://localhost:8000
cd /usr/local/system/projects/entos/external/workspace
case $1 in
"start" )
echo "start python SimpleHTTPServer"
nohup python -m SimpleHTTPServer > /tmp/nohup.out &
;;
"stop" )
echo "stop python SimpleHTTPServer"
kill `ps aux | grep "python -m SimpleHTTPServer"` | grep -v grep | awk '{print $2}' > /dev/null
;;
"restart" )
echo "restart python SimpleHTTPServer"
kill `ps aux | grep "python -m SimpleHTTPServer"` | grep -v grep | awk '{print $2}' > /dev/null
nohup python -m SimpleHTTPServer > /tmp/nohup.out &
;;
*)
echo "need start|stop|restart"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment