如何在背景中在GCP中运行VM?

发布于 2025-01-29 08:50:12 字数 206 浏览 4 评论 0原文

我有一个GCP Linux VM,非常基本的问题:如果我有一个简单的脚本:

import time
for a in range (0,1000):
    print(a)
    time.sleep(10)

当我通过浏览器连接中的SSH进入控制台时,我会运行脚本,但是当我关闭窗口时,它会停止。 即使关闭电脑,我该如何使其运行?

I have a gcp linux VM, very basic question: If I have a simple script like this:

import time
for a in range (0,1000):
    print(a)
    time.sleep(10)

when I enter the console via ssh in browser connection I run the script, but it stops when I close the window.
How do I make it run even when I shut down my PC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰雪之触 2025-02-05 08:50:13

您可以使用NOHUP。

例如:

nohup python myscript.py &

然后您可以关闭会话。该脚本将继续在远程VM上运行,直到完成。

You can use nohup.

For example:

nohup python myscript.py &

And then you may close the session. The script will keep running on the remote VM, til it finishes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文