如何在后台运行Python脚本,即使我注销SSH吗? [英] How to run a Python script in the background even after I logout SSH?

查看:344
本文介绍了如何在后台运行Python脚本,即使我注销SSH吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Python脚本 bgservice.py ,我希望它一直运行,因为它是我构建的web服务的一部分。即使我注销SSH后,我如何使它连续运行?

I have Python script bgservice.py and I want it to run all the time, because it is part of the web service I build. How can I make it run continuously even after I logout SSH?

推荐答案

运行 nohup python bgservice.py& 以忽略挂机信号并继续运行。输出将放在 nohup.out

Run nohup python bgservice.py & to get the script to ignore the hangup signal and keep running. Output will be put in nohup.out.

理想情况下, href =http://cr.yp.to/daemontools/supervise.html =nofollow noreferrer> supervise ,以便可以重新启动如果(当)它死。

Ideally, you'd run your script with something like supervise so that it can be restarted if (when) it dies.

这篇关于如何在后台运行Python脚本,即使我注销SSH吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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