从自身取消分配Ubuntu VM [英] Deallocate a Ubuntu VM from itself

查看:270
本文介绍了从自身取消分配Ubuntu VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure中使用Ubuntu 16.04 VM运行一些GPU计算。通常,我会在晚上进行实验,并希望在计算结束后重新分配VM(以节省一些钱)。我可以从要取消分配的VM运行任何命令以实际对其进行取消分配吗?我应该只使用Azure CLI吗?

I am using a Ubuntu 16.04 VM in Azure to run some GPU computation. Typically, I run my experiments at night and I would like to deallocate the VM when the computation is over (to save some money). Is there any command that I can run from the VM I want to deallocate to actually deallocate it? Shall I just use the Azure CLI? Thanks in advance.

推荐答案

是的,有可能。

当脚本成功运行时,您可以判断返回值。然后,执行Azure CLI来重新分配您的VM。

When your script works successful, you could judge the return value. Then, execute Azure CLI to deallocate your VM.

##your script
if [$? -eq 0];then
 az vm deallocate --resource-group myResourceGroup --name myVM
fi

注意:如果不使用静态IP,则在取消分配VM时它将更改IP。另外,如果要自动启动VM,则可以使用Azure自动化运行手册。

Notes: If you don't use static IP, it will change IP when you deallocate your VM. Also, if you want to start your VM automatically, you could use Azure automation runbook.

这篇关于从自身取消分配Ubuntu VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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