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

遠程關機腳本

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

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:585
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:881
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:574
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:761
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:677
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1005
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:249
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:108
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:799
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:705