当前位置:首页 » 编程软件 » 远程关机脚本

远程关机脚本

发布时间: 2024-11-14 18:50:39

⑴ 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
关机
问题是虚拟机必须关闭了才能进入维护模式,又回到用脚本来自动关闭虚拟机的问题上来了。

⑵ 如何远程通过Xshell实现对linux主机的开、关机及重启

关机的情况无法远程开机,关机命令shutdown,重启命令reboot,使用步骤如下:

1、连接上相应的linux主机,进入到等待输入shell指令的linux命令行状态下。

热点内容
微信棋牌游戏源码 发布:2025-03-16 09:06:17 浏览:112
华为平板访客如何访问存储卡 发布:2025-03-16 09:04:35 浏览:510
如何查看自己的qq号和密码 发布:2025-03-16 09:03:05 浏览:311
为什么安卓杀后台越来越严重 发布:2025-03-16 08:42:34 浏览:881
python解析json 发布:2025-03-16 08:36:22 浏览:566
奥丁镇服务器怎么进 发布:2025-03-16 08:34:04 浏览:5
在优酷看视频会缓存到c盘吗 发布:2025-03-16 08:29:05 浏览:258
口罩辊轴编程 发布:2025-03-16 08:21:52 浏览:580
网易我的世界官方开服务器 发布:2025-03-16 08:16:57 浏览:43
王者荣耀密码怎么改 发布:2025-03-16 08:16:24 浏览:572