bat5连接linux mysql_ESXI 5.5在windows下使用BAT脚本通过SSH进行远程关机?

网上搜到一段脚本用来关闭vm,再关机的

# get all the VMs identifiers

VMID=$(/usr/bin/vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1}')

# loop through all the VMs

for i in $VMID

do

# get their state(turned on,off,whatever)

STATE=$(/usr/bin/vim-cmd vmsvc/power.getstate $i | tail -1 | awk '{print $2}')

# if they are running,turn them off (only works correctly if

# vmware tools are installed on the VMs)

if [ $STATE == on ]

then

/usr/bin/vim-cmd vmsvc/power.shutdown $i

fi

done

#shutdown the host itself

sleep 30

/sbin/shutdown.sh

/sbin/poweroff

实际也可以通过运行命令

esxcli system maintenanceMode set -e y

进入维护模式maintenanceMode(Mode的M为大写)

esxcli system shutdown poweroff -d 60 -r test

关机

问题是虚拟机必须关闭了才能进入维护模式,又回到用脚本来自动关闭虚拟机的问题上来了。

取消

评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值