This article details how to change the ESXi system time and HW clock on your ESXi hypervisor machine via the CLI.
Ideally we want to use NTP to set the system time but if your clock is too far out from the actual time then this will fail and you may see something like this in the syslog file:
ntpd: synchronized to <22.214.171.124>, stratum 1
ntpd: time correction of <54423> seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.
[info 'ha-eventmgr'] Event 91 : NTP daemon stopped. Time correction 1206 > 1000 seconds. Manually set the time and restart ntpd.
The situation was that my VMs were synchronising their time to the ESXi host’s on every reboot, meaning that some important secure system services (in Windows 2008 in particular) were not starting. There isn’t the facility to do this on the DCUI (Direct Console User Interface – the yellow and black screen) so here’s the gen on how to achieve this using the command line.
My first endeavours were using the “date” command, as I’m used to doing in Linux, unfortunately these were met with the error:
~ # date 100410112014
date: can't set date: Function not implemented
Sat Oct 4 10:11:00 UTC 2014
OK, it’s being pernickety so lets use the “-s” flag to SET the time:
~ # date -s 041010112014
date: Setting date not supported; use <esxcli system time set>
Now we’re getting somewhere. The command takes the following parameters:
Usage: esxcli system time set [cmd options]
set Set the system clock time. Any missing parameters will default to the current time
So, to set the system time to 10th April 2014, 10:18 (am):
~ # esxcli system time set -d 10 -H 10 -m 18 -M 04 -y 2014
Also, make sure that we also set the hardware clock time as the system time will revert to this on a reboot:
~ # esxcli hardware clock set -d 10 -H 10 -m 18 -M 04 -y 2014 <- sets the hardware clock to 10th April 2014, 10:18 (am)
To check the hardware and system time we can use the following commands:
esxcli hardware clock get
esxcli system time get
Job done! Now move on to setting the time automatically using NTP.