Created
November 1, 2022 17:47
-
-
Save brahimmachkouri/1c322586e8265dc0398a940f90778920 to your computer and use it in GitHub Desktop.
Proxmox shutdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# get list of VMs on the node | |
VMIDs=$(/usr/sbin/qm list| awk '/[0-9]/ {print $1}') | |
# ask them to shutdown | |
for VM in $VMIDs | |
do | |
/usr/sbin/qm shutdown $VM | |
done | |
#wait until they're done (and down) | |
for VM in $VMIDs | |
do | |
while [[ $(/usr/sbin/qm status $VM) =~ running ]] ; do | |
sleep 1 | |
done | |
done | |
## do the reboot | |
shutdown -r now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment