This would restart api on all of them, one after another.
You write this in pve shell, and its the equivivalent of writing pm2 restart api in each individual evernode vm.
Code: Select all
for vmid in $(seq 301 330); do
echo "=== VM $vmid ==="
if ! qm status "$vmid" 2>/dev/null | grep -q "status: running"; then
echo "Skipped: VM missing or stopped"
continue
fi
qm guest exec "$vmid" -- /bin/bash -lc \
"su - root -c 'pm2 restart api'"
done