A better solution may be to use cron to schedule the shutdown.
There is a definite order of action to properly power-off CSIM system from a remote access.VMware ESXi servers may take a substential anount of time to shutdown, depending of the number of virtual machine running on the server. A god rule of thumb is to consider 2 minutes for each vitual machines, plus 2 minutes for the server itself.
When choosing the time to shutdown, allow enough time for the shutdown to properly complete before the general shutdown of the main electric power, a good practice is 30 minutes.
So if a general failure of the main power is planned for 11:00, you should plan the shutdown time at 10:30 and start working at 10:00. In the following examples, we use 10:30 for the shutdown time.
sudo /sbin/shutdown -h 10:30 &and disconnect from the router;
shutdown -h 10:30 &and disconnect from the firewall.
shutdown -c
to cancel the shutdown sequence;sudo shutdown -p 10:30 &and disconnect from amanda.
For amanda, you cannot cancel the shutdown sequence;
/vmfs/volumes/datastore1/shutdown 635 &and disconnect from the server.
To shutdown a VMware ESXi server, you don't use the time of shutdown as a parameter, but instead you use the number of seconds remaining until the time of shutdown: if the wall clock is 10:19:25 and you want to shutdown at 10:30, that makes it 10 minutes and 35 seconds, that is, 635 seconds.For the ESXi server, you can reconnect and issue a
ps -c |
grep shutdown
to find the process ID of the shell script and
kill the script to cancel the shutdown sequence.
Every virtual machine on the ESXi server will be gracefully shutdown provided that:
- VMware tools are installed on the virtual machine;
- The virtual machine is configured to do a guest shutdown (default is a plain power off) in vSphere client Configuration/Virtual Machine Startup-Shutdown.
On that note, you can also configre the startup to Continue immediately if VMware Tools start.