在终端中运行 python 并且在终端关闭时不终止 [英] Run python in terminal and don't terminate when terminal is closed

查看:53
本文介绍了在终端中运行 python 并且在终端关闭时不终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要制作静态网站.所以我通过 ssh 连接到一些本地服务器,我想在那里制作一个静态网站.然后我用 python 让它工作:

I need to make static website. So I connected via ssh to some local server, where I want to make a static website. Then I used python to make it work:

$ python -m http.server 55550

但是如果我关闭终端,那么 python 程序就会终止.我想关闭我的电脑,但我想让这个进程在那个本地服务器上运行,这样其他人仍然可以访问那个网站.

But if I close terminal, then python program is terminated. I want to shut down my computer, but I want to let this process running on that local server, so other people could still access that website.

我该怎么做?之后,我应该如何终止该进程?

How can I do this? After that, how should I terminate that process later?

感谢您的帮助

推荐答案

使用 nohup shell 内置:

Use the nohup shell builtin:

nohup python -m http.server 55550

要终止进程,只需使用 kill 命令杀死它,就像任何其他进程一样.

To terminate the process, simply kill it using the kill command, just like any other process.

这篇关于在终端中运行 python 并且在终端关闭时不终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆