Understanding Linux Time

The system takes the time from the hardware clock at boot

hwclock allows to set the time at the hardware level

timedatectl sets several aspects of time on the system level

Network Time Protocol (NTP) is a service provided by external servers that can be used to synchronize the time on the system

If the system time is out of sync with NTP by 1,000 seconds, NTP will not update the system’s time

Setting Time with timedatectl

timedatectl --help: Prints available options and commands

timedatectl status: Prints the current settings:

timedatectl status
Local time: Sun 2021-03-21 00:39:38 UTC
Universal time: Sun 2021-03-21 00:39:38 UTC
RTC time: Sun 2021-03-21 00:39:38
Time zone: n/a (UTC, +0000)
System clock synchronized: no
NTP service: active
RTC in local TZ: no

timedatectl list-timezones: Lists all available timezones

timedatectl set-timezone: Sets the system’s timezone

Setting up an NTP Client

  1. Open the /etc/chrony.conf file, then uncomment and edit the line local stratum 10 to local stratum 5
  2. Comment out the line under # Please consider joining the pool ([<http://www.pool.ntp.org/join.html>](<http://www.pool.ntp.org/join.html>)).
  3. Uncomment the line under # Allow NTP client access from local network.
  4. Restart the chronyd service: systemctl restart chronyd
  5. Add the ntp service to the firewall: firewall-cmd --add-service ntp & firewall-cmd --add-service ntp

To use the new NTP Client on the local machine:

  1. Comment out the line under # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  2. Add the line server [IP_ADDR]
  3. Restart the chronyd service: systemctl restart chronyd
  4. Confirm by listing the chronyd sources: chronyc sources

Leave a Reply

Your email address will not be published.