How to synchronise hardware clock (hwclock) with NTP in RHEL / CentOS 7

I have already written an article giving you details steps and examples on how can you make sure your hwclock displays correct time during boot up.

Here I will show you the NTP configurations which must be done to make sure NTP itself syncs the hwclock with local clock during system startup and you need not worry about any more manual configurations.

If you are using HP ProLiant Blade servers then it is always recommended to set the BIOS date and time using SNTP or else for all other hardware make sure your BIOS is pointing to correct date and time.

In Red Hat Enterprise Linux 6, the hwclock command was run automatically on every system shutdown or reboot, but it is not in Red Hat Enterprise Linux 7. When the system clock is synchronized by the Network Time Protocol (NTP) or Precision Time Protocol (PTP), the kernel automatically synchronizes the hardware clock to the system clock every 11 minutes.

Exit the below file and change SYNC_HWCLOCK to "yes"

# vim /etc/sysconfig/ntpdate
# Options for ntpdate
OPTIONS="-p 2"

# Number of retries before giving up

# Set to 'yes' to sync hw clock after successful ntpdate

Next add the list of your NTP servers in the below file

# vim /etc/ntp/step-tickers

This file will be referenced by ntpdate service , below is the content of ntpdate.service

# systemctl cat ntpdate.service
# /usr/lib/systemd/system/ntpdate.service
Description=Set time via NTP



Here as you see the script calls "/usr/libexec/ntpdate-wrapper" which calls "ntpstep=/etc/ntp/step-tickers" to make sure ntp syncs hwclock

Next enable the ntpdate service to make sure it is called at next reboot

# systemctl enable ntpdate.service

NOTE: As long as NTPD daemon is running, you will not be able to start ntpdate service

If you wish to start ntpdate service runtime then you have two options
1. Disable ntpd service and then start ntpdate.service
2. Execute ntpdate using -u variable, with this the service will be called using random port number

To stop NTPD daemon

# systemctl stop ntpd.service

Next start ntpdate service

# systemctl start ntpdate.service

Next again start ntp service

# systemctl start ntpd.service

OR you can execute below command (Here replace the with your NTP server)

# ntpdate -u
27 Apr 20:38:59 ntpdate[13893]: adjust time server offset -0.004723 sec

I hope the article was useful.