I know in Windows Server 2005 you could schedule the individual virtual servers to reboot and then finally, after a set number of seconds, have the main box reboot. Is there a way to do this with ESX? We have 6 virtual servers running on our box; I need the individual servers to reboot and then the main box reboot automatically at a set time every night.
Is this possible?
You could reboot the box with the shutdown command I believe. For example if you wanted to reboot ESX at 8:00
shutdown -r 8:00
Anyway to automate that? Also; do you have to shut down the vservers first? Our end result needs to be this: The box needs to reboot automatically and come back on; also, the vservers need to start back up automatically.-----
Sure you could create a cron job that did it for you in your cron daily tab you could put an entry that would call a script.
crontab -e
0 20 * * * ~/myshutdownscript -h now
Then write a script to shutdown the virtual machines and reboot the box (Oh gosh now I have to try and write a script but here goes:)
To shut down the VMs
for vm in `vmware-cmd -l` ; do
#echo "VM: " $vm
for VMstate in `vmware-cmd "$vm" getstate` ; do
- If the VM is power ON
if ; then
echo " "
echo "Found this VM: " $vm
echo "it is stille on but now i will turn it off"
vmware-cmd "$vm" stop trysoft
fi
done
done
shutdown -r now
(go here for more examples http://www.tooms.dk/?page=http%3A//www.tooms.dk/forum/topic.asp%3FTOPIC_ID%3D131
The following thread has a script for shutting down VMs either hard or soft:
http://communities.vmware.com/thread/62864
At the end of it you could put the ESX server shutdown command.
As far as automation goes, put the script into the cron. "man crontab" for more info.
I have a script that powers down all VM's on an ESX host then shuts down the ESX server, you can modify this script to reboot the ESX host after all vm's are powered off. Then create a scheduled task to "Change the power state of a virtual machine" to power on your vm's. I have not tried to schedule my power down script, if you can figure that out I think you can accomplish what you want.
This document was generated from the following thread: Auto Rebooting of ESX Server & Vservers