<分区>
如何在 ubuntu 后台运行 python 脚本?我尝试使用“&”,例如:
python3 test.py &
但是当我关闭终端时,这个过程似乎也被关闭了,因为我无法再从这个测试脚本中获取任何更新日志。
<分区>
如何在 ubuntu 后台运行 python 脚本?我尝试使用“&”,例如:
python3 test.py &
但是当我关闭终端时,这个过程似乎也被关闭了,因为我无法再从这个测试脚本中获取任何更新日志。
最佳答案
您可以使用 setsid。在你的情况下运行:
setsid python test.py
或者,如评论中所述,您可以使用 nohup。
nohup python test.py
您可以在这个答案中看到它们之间的区别:What's the difference between nohup and a daemon?
关于python - 如何在 ubuntu 后台运行 python 脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43532245/
相关文章:
python - 如何为 pylons 静态(公共(public))文件设置自定义响应 header ?
linux - 需要通过 SFTP 将文件从一台 Linux 机器传输到另一台 Linux 机器
c - "RTLD_NEXT used in code not dynamically loaded"请帮忙
python - 在 python 中使用 cv2.approxPolyDP() 绘制轮廓
python - 如何在Mac上卸载pyenv(由homebrew安装)
python - VScode : Automating conversion of python file to Jupyter notebook with a task