Scheduling VMWare ESXi 4.1 VM Restart

scheduled-taskvmware-esxi

We had a virtual machine running on a VMWare Server host on Windows Server 2003.

The machine is set up with non persistent disks.

We had a windows task schedule set up that ran a batch file to reset the machine each week so that it returned to it's original state.

The batch file that we had running was:

"C:\Program Files\VMware\VMware Server\vmware-cmd" "C:\Virtual Machines\VirtualMachineName\VirtualMachineName.vmx" stop hard
"C:\Program Files\VMware\VMware Server\vmware-cmd" "C:\Virtual Machines\VirtualMachineName\VirtualMachineName1.vmx" start

We have since migrated this machine to the free version of ESXi 4.1.

Can anyone let me know if and how it is possible to schedule such a restart?

Best Answer

  • enabled ssh access to your ESXi
  • add cron job to the root crontab(/var/spool/cron/crontabs/root)

You can start, reboot, stop, and suspend virtual machines using vmware-cmd:

vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx stop soft
vmware-cmd -H <vc_system> -U <user> -P <password> --vihost <esx_host>
/vmfs/volumes/Storage2/testvm/testvm.vmx start soft