Skip to content

Instantly share code, notes, and snippets.

@brahimmachkouri
Created November 1, 2022 17:47
Show Gist options
  • Save brahimmachkouri/1c322586e8265dc0398a940f90778920 to your computer and use it in GitHub Desktop.
Save brahimmachkouri/1c322586e8265dc0398a940f90778920 to your computer and use it in GitHub Desktop.
Proxmox shutdown
#!/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