Schedule Shutdown Esxi (v5)

This script would be using two commands available on the esxi.

  • /sbin/powerOffVms (Stop the current's running vms)
  • /bin/poweroff (Stop the Esx host)

I have called it:
 #! /bin/ash
 echo "shutting down VMs..please wait.."
 echo "done."
 echo "shutting down the host now.."


Apply the execution's rights :

chmod +x /vmfs/volumes/datastore1/


Add this script in /etc/rc.local

/bin/echo "0 22 * * * /vmfs/volumes/datastore1/" >> /var/spool/cron/crontabs/root

This script would stop the vms and the Esxi host everyday at 22h.


On Esxi Version 5.1, editing /etc/rc.local is no longer valid and you need to use /etc/rc.local.d/ instead.

V5.1, add the line into /etc/rc.local.d/

One Reply to “Schedule Shutdown Esxi (v5)”

  1. On my ESXi 5.0 host /bin/poweroff doesn’t work from the Crontab file (/var/spool/cron/crontabs/root), neither does the echo command (/bin/echo and /sbin/echo). All of these are symlinks to /bin/busybox. I suspect that these symlinks are not defined in the environment used by Crontab. However, using the command /bin/busybox poweroff in the Crontab file does work.

Leave a Reply

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