Tag: ntp

  • How to sync NTP time with chrony

    How to sync NTP time with chrony

    chrony is a network time protocol (NTP) implementation. It can be used to keep server time sync with NTP servers.

    To install chrony on RHEL based OS, run

    yum install chrony
    

    On Debian/Ubuntu, run

    apt install chrony
    

    Configure chrony

    On Ubuntu, by default chrony is configured to use ubuntu NTP servers.

    pool ntp.ubuntu.com        iburst maxsources 4
    pool 0.ubuntu.pool.ntp.org iburst maxsources 1
    pool 1.ubuntu.pool.ntp.org iburst maxsources 1
    pool 2.ubuntu.pool.ntp.org iburst maxsources 2
    

    If you need to change NTP servers, you can edit configuration file

    vi /etc/chrony/chrony.conf
    

    Restart chrony

    systemctl restart chrony
    

    Enable chrony

    systemctl enable chrony
    

    Start chrony

    systemctl start chrony
    

    To view status, run

    systemctl status chrony
    

    Display system time information, you can use the command “chronyc tracking”.

    root@ip-172-26-14-120:~# chronyc tracking
    Reference ID    : E9485C92 (prod-ntp-4.ntp4.ps5.canonical.com)
    Stratum         : 3
    Ref time (UTC)  : Sat Jun 10 08:15:27 2023
    System time     : 0.000015639 seconds slow of NTP time
    Last offset     : -0.000025658 seconds
    RMS offset      : 0.000170312 seconds
    Frequency       : 4.834 ppm fast
    Residual freq   : -0.007 ppm
    Skew            : 0.255 ppm
    Root delay      : 0.008501955 seconds
    Root dispersion : 0.001060591 seconds
    Update interval : 260.2 seconds
    Leap status     : Normal
    root@ip-172-26-14-120:~# 
    

    Back to Time

  • How to sync NTP time with systemd-timesyncd

    How to sync NTP time with systemd-timesyncd

    systemd-timesyncd is a system service in Linux operating systems that provides time synchronisation with NTP servers. It continuously adjusts the system clock to ensure accurate timekeeping, which is crucial for various system operations, time-sensitive applications, and network synchronisation.

    To configure systemd-timesyncd, edit file

    vi /etc/systemd/timesyncd.conf
    

    Add following

    [Time]
    NTP=
    FallbackNTP=time.google.com
    

    Leaving NTP= uncommented and assigned to an empty string resets the list of NTP servers, including any per-interface assignments. This prevents inadvertently moving between smeared and un-smeared time servers. Configuring Google Public NTP as the fallback server will cause it to be selected as the only NTP server.

    If you want to use debian maintained NTP servers, use

    [Time]
    NTP=
    FallbackNTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org
    

    Restart systemd-timesyncd

    systemctl restart systemd-timesyncd.service
    

    You can verify NTP server with command

    timedatectl show-timesync | grep ServerName
    

    timedatectl show-timesync

    Back to time