當前位置:首頁 » 編程軟體 » 遠程關機腳本

遠程關機腳本

發布時間: 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命令行狀態下。

熱點內容
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
安卓隱藏的游戲在哪裡 發布:2025-03-16 08:05:31 瀏覽:333
嵌入式伺服器搭建 發布:2025-03-16 07:53:28 瀏覽:684
安卓系統微信登錄設備管理在哪裡 發布:2025-03-16 07:44:55 瀏覽:510
青少兒編程品牌 發布:2025-03-16 07:43:24 瀏覽:633