Using Cron to automate reboot/shutdown of ESX

This week I looked briefly at automating repetitive tasks with the CRON Utility. In this case, I wanted to shutdown/reboot the ESX server at a designated time. This was used in conjunction with ESX’s ability to automatically start-up and shutdown VMs.

Crond is a service which is used to schedule scripts of hourly/daily/weekly/monthly events. VMware utilizes this to run their own scripts, which can be seen in /etc/cron.daily, /etc/hourly and so on. Cron can also handle events such as: on reboot run this script with its @reboot syntax Along side these system-wide cron configurations you can also have per-user cron configurations. In my example, I’m using a per-user cron configuration to shutdown my servers at 9.30pm every evening. My development environment is accessible to some people – but due to physical limitations I cannot run my servers 24/7. So I need them to start-up in the morning and shut down in the evening.

  1. Logon to the Service Console as ROOT
  2. Create a cron configuration file in ROOT’s home directory with

    nano -w crontab

  3. Type in this configuration:


    # run-parts
    30 21 * * * shutdown -h now

    The path statements allow cron to find the shutdown utility which is held in /sbin.

    Requires Free Membership to View

  1. The command shutdown -h now causes ESX to do a full shutdown. The -h forces a halt which stops the swap file and un-mounts the drives. 30 21 is 9:30pm…

    For more information about setting the time value see this link

  2. Save the contab file…
  3. Register this configuration file with crontab with:

    crontrab /root/crontab

    Confirm this has been registered with crond by listing the crontabs for root with:

    crontab -l

    If you wish to remove a scheduled event use:

    crontab -r

  4. Restart the crond service with:

    service crond restart


This was first published in September 2005

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.