Last active
December 20, 2015 19:29
-
-
Save rosickytong/6183859 to your computer and use it in GitHub Desktop.
python -m SimpleHTTPServer
This file contains hidden or 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
| http://blog.sina.com.cn/s/blog_62e7fe670101c4v5.html | |
| python -m SimpleHTTPServer 8000 | |
| 使用上面的命令可以把当前目录发布到8000端口。 | |
| 但是这条命令是当前运行的,不是后台运行的,也就是说如果Ctrl + C,则该端口就会关闭。 | |
| 在上述命令的最后加一个 & ,则该命令产生的进程在后台运行,不会影响当前终端的使用(我们在只有一个bash的环境下)。 | |
| 生成的新的进程为当前bash的子进程,所以,当我们关闭当前bash时,相应的子进程也会被kill掉,这也不是我们想要的结果。 | |
| nohup python -m SimpleHTTPServer 8000& | |
| 在命令的开头加一个nohup,忽略所有的挂断信号,如果当前bash关闭,则当前进程会挂载到init进程下,成为其子进程,这样即使退出当前用户,其8000端口也可以使用。 | |
| nohub命令的解释如下: | |
| nohup 命令 | |
| 用途:不挂断地运行命令。 | |
| 语法:nohup Command [ Arg ... ] [ & ] | |
| 描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命令,添加 & ( 表示“and”的符号)到命令的尾部。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment