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
- Open the
/etc/chrony.conf
file, then uncomment and edit the linelocal stratum 10
tolocal stratum 5
- Comment out the line under
# Please consider joining the pool ([<http://www.pool.ntp.org/join.html>](<http://www.pool.ntp.org/join.html>)).
- Uncomment the line under
# Allow NTP client access from local network.
- Restart the
chronyd
service:systemctl restart chronyd
- 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:
- Comment out the line under # Please consider joining the pool (http://www.pool.ntp.org/join.html).
- Add the line
server [IP_ADDR]
- Restart the
chronyd
service:systemctl restart chronyd
- Confirm by listing the
chronyd
sources:chronyc sources