• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • 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
    RETRIES=2

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

    Next add the list of your NTP servers in the below file
    # vim /etc/ntp/step-tickers
    1.in.pool.ntp.org
    1.asia.pool.ntp.org
    2.asia.pool.ntp.org

    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
    [Unit]
    Description=Set time via NTP
    After=syslog.target network.target nss-lookup.target
    Before=time-sync.target
    Wants=time-sync.target

    [Service]
    Type=oneshot
    ExecStart=/usr/libexec/ntpdate-wrapper
    RemainAfterExit=yes

    [Install]
    WantedBy=multi-user.target

    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 1.in.pool.ntp.org with your NTP server)
    # ntpdate -u 1.in.pool.ntp.org
    27 Apr 20:38:59 ntpdate[13893]: adjust time server 1.in.pool.ntp.org offset -0.004723 sec

    I hope the article was useful.

    Deepak Prasad

    is a techie and an author who is still trying to survive in this IT generation with very little knowledge he has on Linux/Unix, VMware, SAN Storage, Automation, networking etc

    You can follow him on Facebook or Google+

    Do you also have something to share here?

    Become an author and be a part of our GoLinuxHub Team, Click here for more information
    How to synchronise hardware clock (hwclock) with NTP in RHEL / CentOS 7 How to synchronise hardware clock (hwclock) with NTP in RHEL / CentOS 7 Reviewed by Deepak Prasad on Friday, April 27, 2018 Rating: 5

    No comments:

    Powered by Blogger.