category:

Auto shutdown script for Xen VMs on XenServer

In case of a scheduled maintenance which requires your Xen VMs to be shutdown on your Xen server when you are not available, the following script should can be put to use:

Create a script as allvmshutdown.sh with 755 permissions and add the list of VMs as in the example script:

#!/bin/bash
xe vm-shutdown vm=VM1
xe vm-shutdown vm=
VM2
xe vm-shutdown vm=VM3
xe vm-shutdown vm=VM4
xe vm-shutdown vm=VM5
xe vm-shutdown vm=VM6
xe vm-shutdown vm=VM7
xe vm-shutdown vm=VM8
xe vm-shutdown vm=VM9
xe vm-shutdown vm=VM10

To get a list of VMs on the server, run the command #xe vm-list from the command line, which will list the VMs hosted on your Xen host.

Now you just need to add a cron entry to schedule this job. For example, to run script at 02:00 am on Sunday:

crontab -e
*   02 *    *    0           /scripts/allvmshutdown.sh

Note: Do ensure that the script is commented or removed from the crontab, after the maintenance has been completed to prevent this script from recurring.

Share
Comments (1)

One response to “Auto shutdown script for Xen VMs on XenServer”

  1. I use a xenserver that hosts a webserver as well as 13 windows VMs. I need to come up with a way to reboot them about every 4 hours in a staggered fashion. Do you have any advice or can I hire you to help me with this?

Leave a Reply

Your email address will not be published. Required fields are marked *

1 + 2 =

Related:

Stay Updated

Please enter your details below to get
A Free Trial
x + x* =