I'm in the process of moving some servers to AWS. One problem I'm encountering is that my script to synchronize the time using ntpdate and then write that time to the hwclock is failing. When the server reboots, I'd like the time to be close to accurate. However, I can't seem to adjust the hardware clock.
My script reports that the system time and the hardware clock differ by about half a second:
systime: 2018-01-03 05:51:58.529746-0500 hwtime: 2018-01-03 05:51:59.023462996-05:00 diff (sec): 0.493716955184937
I'd expect that running
sudo /sbin/hwclock --utc --systohc would correct the problem. It certainly does on my traditional non-virtualized servers. However, when I run that command, I still see the same half second difference between the system time and the hardware clock.
My instance was created using
ami-d53b3eb5). I'm getting the system time using
date --iso-8601=ns and the hardware time using
sudo /sbin/hwclock --show. I'm comparing them after parsing them with Perl's
Is setting the hardware clock not supported in virtualized environments such as AWS? If that is the case, is there any workaround to ensure that the time remains synchronized when AWS servers reboot?