Fix CentOS 7 and motherboard clock UTC problem

If you have a freshly installed CentOS 7 system, and when you reboot the time is a few hours off, you might find this info useful.

A probably reason for this error is the system is fetching the hardware clock which is not set in UTC, and so the offset is basically doubled. Or possible the hardware clock is set in UTC but GNU/Linux doesn’t know that.

Here’s how to fix it (courtesy of Michael Hampton at Stack Overflow— what doesn’t he know?).

Fix the date.

# You might need to stop ntpd first.
#systemctl stop ntpd

Ensure the date is correct



# sync hardware clock to the system time
hwclock -wu

And just remember to start up ntpd if you need it.


System selecting wrong time due to not UTC

The problem

I use kickstart files to configure my CentOS 7 virtual machines. One problem I discovered is that the vms can get the wrong time from the hwclock. I guess I haven’t mastered ntpd or chronyd. I can always just run ntpdate but haven’t bothered to set up a cronjob/systemd unit for that.
Anyway, I finally discovered how to get the hwclock and system date to actually grab the time correctly from the host OS. If I don’t set the timezone correctly in the kickstart file with the –utc option:

timezone America/New_York --utc

I can go modify /etc/adjtime myself.
An incorrect file:

0.000000 1499048878 0.000000

The correct file replaces the LOCAL with UTC, to tell the system that the hardware clock (hwclock) is showing the UTC time:

0.000000 1499048878 0.000000

A reboot later, and now my vm has the correct time, so I have achieved my ultimate goal of gssapi auth.



  1. That such a file exists as /etc/adjtime