From 951e43f0cccc4873dc41e24900e5384bafe01f63 Mon Sep 17 00:00:00 2001 From: kneutron <50146127+kneutron@users.noreply.github.com> Date: Sat, 2 Mar 2024 12:16:52 -0700 Subject: [PATCH] Add files via upload --- proxmox/proxmox-HIBER-RUNNING-VMS.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 proxmox/proxmox-HIBER-RUNNING-VMS.sh diff --git a/proxmox/proxmox-HIBER-RUNNING-VMS.sh b/proxmox/proxmox-HIBER-RUNNING-VMS.sh new file mode 100644 index 0000000..ade668e --- /dev/null +++ b/proxmox/proxmox-HIBER-RUNNING-VMS.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# 2024.feb kneutron +# REF: https://forum.proxmox.com/threads/shutting-down-all-vm-ct-in-parallel.112519/ + +[ $(which parallel |wc -l) -gt 0 ] || apt-get install -y parallel + +VM_LIST=/dev/shm/vmlist.in + +# 1 2 3 +# processor : 7 +lastcpu=$(grep processor /proc/cpuinfo |tail -n 1 |awk '{print $3}') +[ $lastcpu -gt 1 ] && let lastcpu=$lastcpu-1 + +[ -e "$VM_LIST" ] && rm -f "$VM_LIST" # delete the old file ONLY IF it exists +for vmid in $(qm list |grep running |awk '{print $1}'); do +# echo "qm shutdown $vmid" >>"$VM_LIST" + echo "qm suspend $vmid --todisk" >>"$VM_LIST" +done + +echo "$(date) - HIBER ALL VMS using $lastcpu threads" +time cat "$VM_LIST" |parallel -j $lastcpu --progress +date + +exit;