How do I shut down a python simpleHTTPserver?

前端 未结 8 1298
太阳男子
太阳男子 2020-12-12 12:29

So I\'m trying to learn d3, and the wiki suggested that

To view the examples locally, you must have a local web server. Any web server will work;

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 13:14

    MYPORT=8888; 
    kill -9 `ps -ef |grep SimpleHTTPServer |grep $MYPORT |awk '{print $2}'`
    

    That is it!

    Explain command line :

    • ps -ef : list all process.

    • grep SimpleHTTPServer : filter process which belong to "SimpleHTTPServer"

    • grep $MYPORT : filter again process belong to "SimpleHTTPServer" where port is MYPORT (.i.e: MYPORT=8888)

    • awk '{print $2}' : print second column of result which is the PID (Process ID)

    • kill -9 : Force Kill process with the appropriate PID.

提交回复
热议问题