December 7, 20196 yr I need help with a script. I need a script where I can shutdown/start all VMs except one. I know about start/stopping via virsh, but I cant find information how to do this on all except one particular.
December 8, 20196 yr Not sure if there is a comand to shutdown all except of one but you can virsh shutdown one by one. simply add a line for each VM in your script.
December 8, 20196 yr Author Just now, bastl said: Not sure if there is a comand to shutdown all except of one but you can virsh shutdown one by one. simply add a line for each VM in your script. Yeah I know how to do this, with a manual VM-list, but I dont want to edit that one, each time I create or edit my VMs.
December 8, 20196 yr Author Figured it out In case anyone wants it VM-Shutdown: #!/bin/bash #Empty vm list echo "" > /tmp/vms-running.txt #Get all running vms except backup server for VM in $(virsh list --state-running --name); do if [[ ! "$VM" == "VM-TO-NOT-SHUTDOWN" ]] ; then virsh shutdown "$VM" #Write running vms to list echo "$VM" >> /tmp/vms-running.txt fi done /usr/local/emhttp/webGui/scripts/notify -i normal -s "Veeam started - VMs shutdown" VM-Start: #!/bin/bash #Get all running vms except backup server for VM in $(cat /tmp/vms-running.txt); do virsh start "$VM" done /usr/local/emhttp/webGui/scripts/notify -i normal -s "Veeam done - VMs started" Edited December 9, 20196 yr by ZataH
Archived
This topic is now archived and is closed to further replies.