Search the VMware Knowledge Base (KB)
View by Article ID

Automating the process of starting and stopping virtual machines on VMware ESX\ESXi (850)

  • 29 Ratings

Details

This article explains how to configure the virtual machines to start and stop automatically when powering an ESX Server host on and off. These settings are set on a per host basis. If you vMotion the virtual machine off the host, the settings are not retained.

Solution

ESX 4.x, ESXi 5.x, and 6.0

VMware vCenter server 4.x, 5.x, and 6.0 includes the ability to configure startup ordering. To configure these startup options:

Note: The Virtual Machine Startup and Shutdown (automatic startup) feature is disabled for all virtual machines residing on hosts that are in (or moved into) a VMware HA enabled cluster. Automatic startup is not supported when the virtual machine is HA enabled. As a result, starting with vCenter Server 5.0 Update 1, the Allow virtual machines to start and stop automatically with the system is available though enabling this feature has no affect at this time.

  1. Access the settings:
    1. Give focus to the host in vCenter.
    2. Click the Configuration tab.
    3. Select Virtual Machine Startup / Shutdown under Software.
    4. Click Properties in the upper right hand side of the window.

  2. Select the options you want:
    1. In order to be able to configure any options, enable Allow virtual machines to start and stop automatically with the system.
    2. Enter a value for the Default Startup Delay, in order to delay the startup activity for a period of time after the boot process completes.

      Note: It may be required to shutdown the virtual machine to apply this setting if you receive the error:

      The attempted operation cannot be performed in the current state (Powered on)

    3. Enter a value for the Default Shutdown Delay, in order to delay the shutdown activity for a period of time. Select the Shutdown Action to be performed:

      • Guest Shutdown, to shut down the guest gracefully. This requires an updated version of VMware Tools to be installed in the guest.
      • Power off, to abruptly stop power to the virtual machine, such as pulling the power cord on a physical machine.
      • Suspend, to pause the virtual machine at that moment in time, like hibernating a physical machine.

    4. To start up the virtual machines in a particular order, configure the three Startup Order categories:

      • Automatic: This category allows you to choose the sequence, by moving machines into this category, then arranging them in order.
      • Any order: In this category, the machines are started in whatever sequence the host prefers (more or less randomized).
      • Manual: In this category, the default, the machines are not automatically restarted. You must power them on manually.

  3. Click OK when finished.

VMware ESX 3.0 and 3.5

You can manage startup and shutdown options using the VMware Infrastructure or vSphere client.

To manage virtual machine startup and shutdown options:

  1. Log into the client and select an ESX host from the inventory.
  2. Click the Configuration tab.
  3. Under Virtual Machine Startup/Shutdown, configure your virtual machine startup options, as required.

Using vmware-cmd for ESX Server 2.1 and 2.5

Starting with ESX Server 2.1, the Management Interface provides start and stop options for virtual machines. The script vmstartstop.pl was also removed and the functions provided by that script were incorporated into vmware-cmd.

For more information, see Setting Startup and Shutdown Options for a Virtual Machine in the ESX Server 2.5 Administration Guide.

The VMware Scripting API User's Manual discusses vmware-cmd command syntax. For more information, see Scripting API Developer Documentation.

Using vmstartstop.pl for ESX Server 2.0.1 and earlier versions

To automatically start virtual machines, add one of these configuration options to the virtual machine's configuration (.cfg or .vmx) file:

  • autostart = true
  • autostart = poweron
  • autostart = resume

    Notes:
    • The true and poweron settings are treated the same.
    • Use the resume setting if you have suspended the virtual machine and want it to resume automatically.

The vmware init script calls /usr/sbin/vmstartstop.pl script. This script looks for virtual machines listed in vm-list that contain one of the preceding options in the configuration files.

If you want to automatically shut down or suspend the virtual machine as well, add one of these configuration options to the virtual machine's configuration file:

  • autostop = suspend
  • autostop = poweroff

To stagger the startup of virtual machines, add this option to each virtual machine's configuration file:

autostart.delay = n

where n is the number of seconds ESX host waits after powering on this virtual machine before it proceeds to the next virtual machine.

Example: If you add the option autostart delay = 60, ESX waits one minute after it starts this virtual machine before starting the next virtual machine.

The same is true for automatically stopping the virtual machines. Use this configuration option:

autostop.delay = n

Notes:

  • You can set a maximum delay of two minutes (120 seconds) between stopping each virtual machine.
  • The stop script loops for up to a maximum of five minutes, until all virtual machines are stopped.
  • This information is documented in the comments in the /usr/sbin/vmstartstop.pl file.


Additional Information

For translated versions of this article, see:

Tags

virtual-machine-start-stop

Keywords

URLZ; 850; Autostop; Autostart; startup; shutdown

Update History

10/05/2010 - Added steps for ESX 3.x 07/13/2011 - Added steps for ESX 4.x 01/30/2014 - Added product ESXi 5.5

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback

  • 29 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.

What can we do to improve this information? (4000 or fewer characters)




Please enter the Captcha code before clicking Submit.
  • 29 Ratings
Actions
KB: