简体   繁体   English

关闭本地计算机后,如何通过 SSH 连接到 Azure VM 并在其上永远运行程序?

[英]How do I SSH to an Azure VM and run a program on it forever after shutting off my local machine?

I want to SSH to a VM that I set up on Azure and I want to run a program on the that has an infinite while loop that scrapes some data from the internet every 10 minutes.我想通过 SSH 连接到我在 Azure 上设置的 VM,并且我想运行一个程序,该程序具有无限的 while 循环,每 10 分钟从互联网上抓取一些数据。 The only problem is that I need it to run after I disconnect from the SSH session and shutdown my local machine.唯一的问题是我需要它在我从 SSH 会话断开连接并关闭我的本地机器后运行。 I have tried screen and nohup, but those don't seem to persist after I shut down my local machine.我尝试过 screen 和 nohup,但在我关闭本地机器后,这些似乎并没有持续存在。 Maybe there is some other way to do it better on Azure?也许还有其他方法可以在 Azure 上做得更好?

You can specify the cron script or any other automation script by using the user data for your virtual machines.您可以使用虚拟机的用户数据指定 cron 脚本或任何其他自动化脚本。 This way, anytime the machine is reinitialized, your instructions will persist and will provision your resource accordingly.这样,无论何时重新初始化机器,您的指令都将保留并相应地配置您的资源。

This is basically what I wanted to do.这基本上就是我想做的。 I can then have a program with an infinite loop that runs every 10 minutes.然后我可以有一个无限循环的程序,每 10 分钟运行一次。
https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session https://askubuntu.com/questions/8653/how-to-keep-processes-running-after-ending-ssh-session

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Powershell 从我的本地计算机在 Azure Windows 虚拟机 (VM) 中运行“sysprep /generalize”? - How to run "sysprep /generalize” in Azure Windows Virtual Machine (VM) from my local machine using Powershell? 如何在本地计算机上使用azure运行terraform init - How can I run terraform init with azure on my local machine 我们如何在本地计算机和Azure VM之间同步代码? - How do we sync code between local machine and Azure VM? 如何连接到本地计算机上的Azure Compute模拟器 - How do I connect to a Azure Compute Emulator on my local machine 如何与Azure VM计算机上的Springboot应用程序通信? - How do I communicate with a Springboot application on an Azure VM machine? 我无法从本地计算机ping Windows Azure VM的VIP - I can't ping windows azure VM's VIP from my local machine 如何/无需在云中手动运行RDP即可运行Azure VM? - How do i/is it possible to run my Azure VM without running the RDP manually aka somewhere in the cloud? 如何在不将其添加到防火墙的情况下从本地计算机连接到 azure sql? 注意 - 公共访问已关闭 - How can i connect to azure sql from my local machine without adding it to firewall? Note - Public acess is turned off 如何使用本地Azure Cli安装运行Azure Cli脚本 - How do I run Azure Cli Script using my local Azure Cli installation 我如何知道我的Azure角色实例VM是否已重新启动? - How do I know if my Azure role instance VM was restarted?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM