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

远程关机脚本

发布时间: 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命令行状态下。

热点内容
linux安全狗 发布:2025-09-16 01:51:18 浏览:636
bash脚本格式 发布:2025-09-16 01:42:02 浏览:504
ftp访问错误代码550 发布:2025-09-16 01:32:21 浏览:438
打lol什么配置要求 发布:2025-09-16 01:32:14 浏览:59
香港绩点算法 发布:2025-09-16 01:25:33 浏览:934
集合顺序存储 发布:2025-09-16 01:17:31 浏览:582
安卓如何开启应用数据 发布:2025-09-16 00:51:14 浏览:584
it固定资产管理系统源码 发布:2025-09-16 00:35:42 浏览:357
Linux是搭建www服务器 发布:2025-09-16 00:35:34 浏览:342
php显示文字 发布:2025-09-16 00:20:25 浏览:283