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

遠程關機腳本

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

熱點內容
h5加密 發布:2025-09-19 12:13:11 瀏覽:780
網貸系統源碼下載 發布:2025-09-19 10:56:45 瀏覽:111
腳本被黑 發布:2025-09-19 10:51:27 瀏覽:504
android自定義命名空間 發布:2025-09-19 10:31:34 瀏覽:460
凱立德導航文件夾名稱 發布:2025-09-19 10:31:27 瀏覽:33
獅山編程 發布:2025-09-19 10:14:45 瀏覽:784
androidshape畫圓 發布:2025-09-19 10:13:21 瀏覽:836
c語言if復合語句 發布:2025-09-19 10:12:30 瀏覽:717
C語言有什麼特點 發布:2025-09-19 09:54:54 瀏覽:823
c語言strupr 發布:2025-09-19 09:47:52 瀏覽:686