restart api on multiple nodes

Post Reply
wroomwroom
Posts: 40
Joined: Wed Jul 31, 2024 5:59 pm

restart api on multiple nodes

Post by wroomwroom »

Notice seq 301 330, this would be vm 301-330.

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
Post Reply