Shutdown al VM and node when some VM are inactive

Frigg

Active Member
Sep 4, 2016
63
2
28
52
Hello,

I'm looking for a script to shutdown all VM and my node when VM 120 and 600 are not running (shutdowned).
Up to date, I'm using a script to shutdown the node, when no vm are active:
#!/bin/bash
qm list | grep running
if [ $? -eq 0 ]
then
shutdown -h now
fi

I guess the "if" commande have to be modified, but I don't know how to write it. Could someone help me ?

Thanks for helping
hervé
 
Try it with something like this:
if [ "$(qm status 120)" = "status: stopped" ] && [ "$(qm status 600)" = "status: stopped" ]; then shutdown -h now; fi
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!