• 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

    # 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
    After=syslog.target network.target nss-lookup.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.

    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 admin on Friday, April 27, 2018 Rating: 5

    No comments:

    Powered by Blogger.