In modern computing, accurate time keeping is absolutely critical. Therefore, as a good system administrator the solutions for timekeeping on Linux operating system are powerful, mature and usually work without much interference. Normally, when a Linux computer boots up, it starts keeping time. This is because of system clock, since it is updated by the operating system. Also, in modern computers there is hardware or real time clock. This hardware clock is usually a feature of the motherboard and keeps time regardless if the pc is running or not. During boot, the system time is about from the hardware clock, except for the foremost part these two clocks run independently of every other.
In this guide, we are going to learn how to manage Linux system date and time mainly system and hardware clocks.
Working with Time Zones
One of the foremost important aspects of your time is that the zone . Each country selects one or longer zones, or offsets from the quality Coordinated Greenwich Mean Time (UTC) time, to work out time within the country.
Local Versus Universal Time
In Linux the system clock is set to UTC that is Coordinated Universal Time, which is the local time at Greenwich, United Kingdom. Usually a user wants to understand their civil time . Local time is calculated by taking UTC time and applying an offset supported zone and Daylight Savings. The system clock are often set to either UTC time or civil time , but it’s recommended that it even be set to UTC time.
Displaying Current Time Zone
Syntax:
date [OPTION]… [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Use the date
command with no options to determine current time zone or local time setting for your Linux system:
$ date
Fri 21 May 2023 04:01:19 PM EAT
With -u
option date
command display the current UTC time:
$ date -u
Fri 21 May 2023 01:03:17 PM UTC
date Command Commonly Used Options
These are;
-I
: Date/time in ISO 8601 format. Appending=date
will limit the output to date only. Other formats arehours
,minutes
,seconds
andns
for nanoseconds.-R
: Returns date and time in RFC 5322 format.--rfc-3339
: Returns date and time in RFC 3339 format.--debug
: annotate the parsed date, and warn about questionable usage to stderr.-d, --date=STRING
: display time described by STRING, not ‘now’.
You can format the current time as Unix time:
$ date +%s
1621603116
Unix time is used internally on most Unix-like systems. It stores UTC time as the number of seconds since Epoch, which has been defined as January 1st, 1970.
Using -d
or --date=STRING
option to format a time that is not the current time:
$ date --date='@1621603116'
Fri 21 May 2023 04:18:36 PM EAT
Using the --debug
option can be very useful for ensuring that a date can be successfully parsed. Observe what happens when passing a valid date to the command:
$ date --debug --date="Fri 21 May 2023 04:18:36 PM EAT"
date: parsed day part: Fri (day ordinal=0 number=5)
date: parsed date part: (Y-M-D) 2023-05-21
date: parsed time part: 04:18:36pm
date: parsed local_zone part: isdst=0
date: input timezone: system default
date: using specified time as starting value: '16:18:36'
date: warning: day (Fri) ignored when explicit dates are given
date: starting date/time: '(Y-M-D) 2023-05-21 16:18:36'
date: '(Y-M-D) 2023-05-21 16:18:36' = 1621603116 epoch-seconds
date: timezone: system default
date: final: 1621603116.000000000 (epoch-seconds)
date: final: (Y-M-D) 2023-05-21 13:18:36 (UTC)
date: final: (Y-M-D) 2023-05-21 16:18:36 (UTC+03)
Fri 21 May 2023 04:18:36 PM EAT
This can be a handy tool when troubleshooting an application that generates a date.
date format command sequences
%a
: The abbreviated weekday name%A
: The full weekday name%b
: The abbreviated month name%B
: The full month name%c
: The date and time%C
: The century (e.g., 20)%d
: The numeric day of month%D
: The full numeric date%e
: The day of month, space padded%F
: The full date in SQL format (YYYY-MM-dd)%g
: The last two digits of year of the ISO week number%G
: The year of the ISO week number%h
: An alias for %b%H
: The hour in 24-hour format%I
: The hour in 12-hour format%j
: The numeric day of year%k
: The hour in 24-hour format, space padded%l
: The hour in 12-hour format, space padded%m
: The numeric month%M
: The minute%n
: A newline character%N
: The nanoseconds%p
: AM or PM%P
: Lowercase am or pm%r
: The full 12-hour clock time%R
: The full 24-hour hour and minute%s
: The seconds since 1970-01-01 00:00:00 UTC%S
: The second%t
: A tab character%T
: The full time in hour:minute:second format%u
: The numeric day of week; 1 is Monday%U
: The numeric week number of year, starting on Sunday%V
: The ISO week number%w
: The numeric day of week; 0 is Sunday%W
: The week number of year, starting on Monday%x
: The locale’s date representation as month/day/year or day/month/year%X
: The locale’s full time representation%y
: The last two digits of the year%Y
: The full year%z
: The time zone in +hhmm format%:z
: The time zone in +hh:mm format%::z
: The time zone in +hh:mm:ss fotmat%:::z
: The numeric time zone with: to necessary precision%Z
: The alphabetic time zone abbreviation
The date
command is the Swiss army knife of time and date commands. It allows you to display the time and date in a multitude of formats, and it lets you set the time and/or date. The +
option allows you to specify the format used to display the time or date value by defining command sequences.
Example:
$ date +"%A, %B %d %Y %::z"
Friday, May 21 2023 +03:00:00
Setting Time Zone
Setting zone information may be a standard step when installing Linux on a replacement machine. If there’s a graphical installation process, this may presumably be handled with none further user input.
The /usr/share/zoneinfo
directory contains information for the different time zones that are possible. In the zoneinfo directory, there are subdirectories that contain the names of continents also as other symbolic links. It is recommended to seek out your region’s zoneinfo ranging from your continent.
zoneinfo
files contain rules required to calculate the local time offset in relation to UTC, and they also are important if your region observes Daylight Savings Time. The contents of /etc/localtime
will be read when Linux needs to determine the local time zone. In order to set the time zone without the use of a GUI, the user should create a symbolic link for their location from /usr/share/zoneinfo
to /etc/localtime
.
Example:
sudo ln -s /usr/share/zoneinfo/Africa/Nairobi /etc/localtime
it is often recommended that after setting the correct time zone, run the following command with root privileges;
sudo hwclock --systohc
The above command will set the hardware clock from the system clock (that is, the real-time clock will be set to the same time as date
).
We can read our local time zone with cat
command;
$ cat /etc/timezone
Africa/Nairobi
Setting Date and Time
Using date Command
With root privileges, you can set date and time using --set
or -s
options with date
command.
Example:
$ sudo date --set="21 May 2023 05:40:11"
Fri 21 May 2023 05:40:11 AM EAT
You can set the time independently with %T
sequence.
Example:
$ sudo date +%T -s "05:55:00"
05:55:00
Also, you can set the date independently.
Example:
$ sudo date +%Y%m%d -s "20230521"
20230521
In the above command, we must specify the sequences so that our string is parsed properly. For example %Y
refers to the year, and so the first four digits 2023
will be interpreted as the year 2023.
After changing system time, it is recommended to also set the hardware clock so that both system and hardware clocks are synchronised using the following command.
sudo hwclock --systohc
systohc means “system clock to hardware clock”.
Using hwclock Command
hwclock
is an administration tool for the time clocks. it’s used to:
- display the Hardware time ,
- set the Hardware Clock to a specified time,
- set the Hardware Clock from the System Clock,
- set the System Clock from the Hardware Clock,
- catch abreast of Hardware Clock drift,
- correct the System Clock timescale,
- set the kernel’s timezone, NTP timescale, and epoch (Alpha only),
- predict future Hardware Clock values supported its drift rate.
Syntax:
hwclock [function] [option…]
With superuser privileges ‘sudo
‘, hwclock
command is used to view the time as maintained on the real-time clock;
$ sudo hwclock
2023-05-21 18:51:05.024773+03:00
Using the option --verbose
will return more output which might be useful for troubleshooting;
$ sudo hwclock --verbose
hwclock from util-linux 2.34
System Time: 1621612337.605673
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1621608334 seconds after 1969
Last calibration done at 1621608334 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2023/05/21 15:52:18
Hw clock time : 2023/05/21 15:52:18 = 1621612338 seconds since 1969
Time since last adjustment is 4004 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2023-05-21 18:52:17.332530+03:00
In the above output, the Calculated Hardware Clock drift
can tell you if system time and hardware time are deviating from one another.
Using --set
option, hwclock
set the Hardware Clock to the time given by the –date option, and update the timestamps in /etc/adjtime.
sudo hwclock --set --date '05/21/2023 19:15:19'
After setting the hardware clock, we will need to update the system clock from it with sudo hwclock --hctosys
command;
sudo hwclock --hctosys
We can now confirm confirm the date and time set with sudo hwclock command
;
$ sudo hwclock
2023-05-21 19:16:39.774896+03:00
Using timedatectl Command
timedatectl
may be used to query and change the system clock and its settings, and enable or disable time synchronization services.
Syntax:
timedatectl [OPTIONS…] {COMMAND}
By default, when you run timedatectl
command it shows current settings of date and time in the system;
$ timedatectl
Local time: Fri 2023-05-21 19:41:28 EAT
Universal time: Fri 2023-05-21 16:41:28 UTC
RTC time: Fri 2023-05-21 16:37:45
Time zone: Africa/Nairobi (EAT, +0300)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
timedatectl
command is also used to enable network time synchronization;
$ timedatectl set-ntp true
==== AUTHENTICATING FOR org.freedesktop.timedate1.set-ntp ===
Authentication is required to control whether network time synchronization shall be enabled.
Authenticating as: frank,,, (frank)
Password:
==== AUTHENTICATION COMPLETE ===
We can confirm if the network time synchronization service is running or active as per the above output;
$ systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-05-21 19:44:54 EAT; 1min 23s ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 704766 (systemd-timesyn)
Status: "Idle."
Tasks: 2 (limit: 2317)
Memory: 1.3M
CGroup: /system.slice/systemd-timesyncd.service
└─704766 /lib/systemd/systemd-timesyncd
May 21 19:44:53 bett systemd[1]: Starting Network Time Synchronization...
May 21 19:44:54 bett systemd[1]: Started Network Time Synchronization.
timedatectl
command is also used to set date and time;
$ sudo timedatectl set-time '2023-05-21 19:55:00'
timedatectl
command is also used to set timezone;
timedatectl
command is used to set the local time zone on systemd
based Linux systems when no GUI exists. timedatectl
will list possible time zones and then the time zone can be set using one of these as an argument.
Let’s list available timezones;
$ timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Algiers
Africa/Bissau
Africa/Cairo
Africa/Casablanca
Africa/Ceuta
Africa/El_Aaiun
Africa/Johannesburg
Africa/Juba
Africa/Khartoum
Africa/Lagos
Africa/Maputo
Africa/Monrovia
Africa/Nairobi
Africa/Ndjamena
Africa/Sao_Tome
Africa/Tripoli
Africa/Tunis
Africa/Windhoek
America/Adak
America/Anchorage
America/Araguaina
America/Argentina/Buenos_Aires
America/Argentina/Catamarca
America/Argentina/Cordoba
America/Argentina/Jujuy
America/Argentina/La_Rioja
America/Argentina/Mendoza
America/Argentina/Rio_Gallegos
Now let’s set the timezone to Africa/Nairobi
;
$ timedatectl set-timezone Africa/Nairobi
We can confirm the above set timezome using timedatectl
command;
$ timedatectl
Local time: Fri 2023-05-21 20:03:34 EAT
Universal time: Fri 2023-05-21 17:03:34 UTC
RTC time: Fri 2023-05-21 17:03:35
Time zone: Africa/Nairobi (EAT, +0300)
System clock synchronized: no
NTP service: inactive
RTC in local TZ: no
Understanding the Network Time Protocol
The Network Time Protocol (NTP) may be a network protocol wont to synchronize clocks over a network so as to supply accurate time. The clocks can be on personal computer systems, network routers, servers, and so on. Programs implementing NTP can typically operate as both a client and a server, and they can perform peer-to-peer as well. NTP uses a hierarchical structure to disseminate time. Reference clocks are connected to servers at the highest of the hierarchy. These servers are Stratum 1 machines and typically are not accessible to the public. Stratum 1 machines are however accessible to Stratum 2 machines, which are accessible to Stratum 3 machines then on. Stratum 2 servers are accessible to the general public , as are any machines lower within the hierarchy. When fixing NTP for an outsized network, it’s good practice to possess a little number of computers hook up with Stratum 2+ servers, then have those machines provide NTP to all other machines.
Terms Used with NTP
- Offset: This refers to the absolute difference between system time and NTP time. For example, if the system clock reads 12:00:02 and NTP time reads 11:59:58, then the offset between the two clocks is four seconds.
- Step: If the time offset between the NTP provider and a consumer is greater than 128ms, then NTP will perform a single significant change to system time, as opposed to slowing or speeding the system time. This is called stepping.
- Slew: Slewing refers to the changes made to system time when the offset between system time and NTP is less than 128ms. If this is the case, then changes will be made gradually. This is referred to as slewing.
- Insane Time: If the offset between system time and NTP time is greater than 17 minutes, then the system time is considered insane and the NTP daemon will not introduce any changes to system time. Special steps will have to be taken to bring system time within 17 minutes of proper time.
- Drift: Drift refers to the phenomenon where two clocks become out of sync over time. Essentially if two clocks are initially synchronised but then become out of sync over time, then clock drift is occurring.
- Jitter: Jitter refers to the amount of drift since the last time a clock was queried. So if the last NTP sync occurred 17 minutes ago, and the offset between the NTP provider and consumer is 3 milliseconds, then 3 milliseconds is the jitter.
Implementing NTP Client Program
To implement NTP client program, we employ the NTP daemon (ntpd
) or use the newer chrony daemon (chronyd
).
Using the NTP Daemon
The system time is compared to network time on a daily schedule. For this to figure we must have a daemon running within the background. For many Linux systems, the name of this daemon is ntpd. ntpd will allow a machine to not only be a time consumer (that is, ready to sync its own clock from an outdoor source), but also to supply time to other machines.
By default, ntp package may be installed in some distributions. Let’s now install.
Installing npt Package
On Ubuntu/Debian:
sudo apt update
sudo apt install -y ntp
On Centos:
sudo yum update
sudo yum install -y ntp
other than ntpd
, ntp
is both a client and daemon.
After installing ntp
we can check if the service is active;
$ systemctl status ntp.service
● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2023-05-22 08:27:47 EAT; 18min ago
Docs: man:ntpd(8)
Main PID: 358325 (ntpd)
Tasks: 2 (limit: 9361)
Memory: 2.2M
CGroup: /system.slice/ntp.service
└─358325 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 127:137
May 22 08:27:56 frank ntpd[358325]: Soliciting pool server 2001:67c:1560:8003::c7
May 22 08:31:21 frank ntpd[358325]: Soliciting pool server 2001:67c:1560:8003::c8
May 22 08:32:09 frank ntpd[358325]: Soliciting pool server 64:ff9b::a29f:c801
May 22 08:32:12 frank ntpd[358325]: Soliciting pool server 64:ff9b::a29f:c801
May 22 08:32:21 frank ntpd[358325]: Soliciting pool server 2001:bc8:255e:100::1
May 22 08:32:22 frank ntpd[358325]: Soliciting pool server 64:ff9b::a29f:c801
May 22 08:33:36 frank ntpd[358325]: kernel reports TIME_ERROR: 0x2041: Clock Unsynchronized
May 22 08:37:39 frank ntpd[358325]: 91.189.89.198 local addr 192.168.43.196 -> <null>
May 22 08:37:44 frank ntpd[358325]: 91.189.91.157 local addr 192.168.43.196 -> <null>
May 22 08:37:44 frank ntpd[358325]: 91.189.94.4 local addr 192.168.43.196 -> <null>
The above output shows that the service is active.
Configuring the NTP daemon
The file /etc/ntp.conf contains configuration information about how your system synchronises with network time. This file can be read and modified using vi
or nano
.
By default, the NTP servers used will be specified in a section like this;
$ grep ^pool /etc/ntp.conf
pool 0.ubuntu.pool.ntp.org iburst
pool 1.ubuntu.pool.ntp.org iburst
pool 2.ubuntu.pool.ntp.org iburst
pool 3.ubuntu.pool.ntp.org iburst
pool ntp.ubuntu.com
You can still add NTP servers through the following syntax;
server (IP Address)
server server.url.localhost
Commonly, /etc/ntp.conf
will be populated with a server pool called pool.ntp.org
. So for example, pool 0.ubuntu.pool.ntp.org iburst
is a default NTP pool provided to Ubuntu machines.
Managing the NTP Service
ntpq
is a utility for monitoring the status of NTP. Once the NTP daemon has been started and configured, ntpq
can be used to check on its status:
$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
0.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
1.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
2.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
3.ubuntu.pool.n .POOL. 16 p - 64 0 0.000 0.000 0.000
ntp.ubuntu.com .POOL. 16 p - 64 0 0.000 0.000 0.000
+pugot.canonical 131.188.3.220 2 u 137 256 377 214.440 -21.256 12.010
+alphyn.canonica 132.163.96.1 2 u 136 256 377 277.390 -29.006 18.195
-chilipepper.can 17.253.34.253 2 u 83 256 377 229.871 -19.059 10.795
+time.cloudflare 10.5.8.4 3 u 150 256 377 41.241 -27.297 19.783
+time.cloudflare 10.5.8.4 3 u 144 256 377 42.556 -25.421 18.082
*golem.canonical 37.15.221.189 2 u 199 256 377 228.798 -22.788 12.908
In this case -p
is for print and it will print a summary of peers. Host addresses can also be returned as IP addresses using -n
.
The above output has the following columns;
remote
: hostname of the NTP provider.refid
: Reference ID of the NTP provider.st
: Stratum of the provider.when
: Number of seconds since the last query.poll
: Number of seconds between queries.reach
: Status ID to indicate whether a server was reached. Successful connections will increase this number by 1.delay
: Time in ms between query and response by the server.offset
: Time in ms between system time and NTP time.jitter
: Offset in ms between system time and NTP in the last query.
Using the chrony Daemon
The chrony daemon (chronyd) has many improvements over ntpd. It can keep accurate time even on systems that have busy networks or that are down for periods of your time , and even on virtualized systems. In addition, it synchronizes the system clock faster than does ntpd, and it can easily be configured to act as a local time server itself. With few exceptions, most distributions recommend that you simply employ the chrony service for software clock synchronization.
By default, chrony package may be installed in some distributions. Let’s now install.
Installing npt Package
On Ubuntu/Debian:
sudo apt update
sudo apt install -y chrony
On Centos:
sudo yum update
sudo yum install -y chrony
After installing chrony
we can check if the service is active;
$ systemctl status chronyd
● chrony.service - chrony, an NTP client/server
Loaded: loaded (/lib/systemd/system/chrony.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2023-05-22 09:54:43 EAT; 1min 56s ago
Docs: man:chronyd(8)
man:chronyc(1)
man:chrony.conf(5)
Main PID: 588397 (chronyd)
Tasks: 2 (limit: 9361)
Memory: 2.3M
CGroup: /system.slice/chrony.service
├─588397 /usr/sbin/chronyd -F -1
└─588398 /usr/sbin/chronyd -F -1
May 22 09:54:43 frank systemd[1]: Starting chrony, an NTP client/server...
May 22 09:54:43 frank chronyd[588397]: chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 -DEBUG)
May 22 09:54:43 frank chronyd[588397]: Initial frequency -20.550 ppm
May 22 09:54:43 frank chronyd[588397]: Loaded seccomp filter
May 22 09:54:43 frank systemd[1]: Started chrony, an NTP client/server.
May 22 09:54:53 frank chronyd[588397]: Selected source 91.189.89.198
May 22 09:54:54 frank chronyd[588397]: Source 62.12.173.11 replaced with 80.153.195.191
May 22 09:55:59 frank chronyd[588397]: Selected source 91.189.89.199
Configuring the chrony Daemon
The primary configuration file for chrony
is that the chrony.conf
file, and it’s going to be stored within the /etc/ or the /etc/chrony/ directory. Typically, there is no need to modify anything in this configuration file, but you might want to look at a few items. The configuration file contains, among other directives, the NTP time servers to use. The directive name for setting these is either server or pool. For chrony
, the server directive is usually used for one time server designation, whereas pool indicates a server pool.
Looking at the pool directives in the /etc/chrony/chrony.conf
file;
$ grep ^pool /etc/chrony/chrony.conf
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 modify the configuration and chronyd is not already started, to start it use super user privileges and the systemctl command: systemctl start chronyd
. If chronyd is already started and you have to modify the configuration file, you’ll need to restart it instead: systemctl restart chronyd
.
Managing the chrony Service
The chrony
service provides the chronyc
command-line utility for managing it. Several commands are available that are similar to or that surpass the ntpd
commands. If you know how to use ntpq -p
for viewing your system’s time sources, you can also use chronyc sources -v
instead.
Looking at source time servers via the chronyc sources -v
command;
$ chronyc sources -v
210 Number of sources = 10
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^+ chilipepper.canonical.com 2 7 377 86 +18ms[ +18ms] +/- 136ms
^+ pugot.canonical.com 2 7 373 350 +6464us[ -817us] +/- 146ms
^+ alphyn.canonical.com 2 7 335 220 +20ms[ +18ms] +/- 200ms
^+ golem.canonical.com 2 7 375 220 -12ms[ -14ms] +/- 150ms
^* time.cloudflare.com 3 7 377 29 +16ms[ +16ms] +/- 151ms
^+ ntp1.kashra-server.com 2 6 173 221 -874us[-2470us] +/- 128ms
^? time.cloudflare.com 0 6 0 - +0ns[ +0ns] +/- 0ns
^? time.cloudflare.com 0 6 0 - +0ns[ +0ns] +/- 0ns
^? ntp1.icolo.io 0 6 0 - +0ns[ +0ns] +/- 0ns
^? ntp0.icolo.io 0 6 0 - +0ns[ +0ns] +/- 0ns
Viewing time server stats via the chronyc sourcestats
command;
$ chronyc sourcestats
210 Number of sources = 10
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
chilipepper.canonical.com 19 13 1180 +5.597 16.765 +14ms 7018us
pugot.canonical.com 17 14 20m -11.711 45.839 -10ms 17ms
alphyn.canonical.com 18 11 1180 -3.892 15.065 +438us 5231us
golem.canonical.com 18 11 1182 -4.293 31.863 -5765us 11ms
time.cloudflare.com 20 9 20m +8.220 18.974 +5081us 9157us
ntp1.kashra-server.com 9 6 917 -11.986 49.739 -709us 7157us
time.cloudflare.com 0 0 0 +0.000 2000.000 +0ns 4000ms
time.cloudflare.com 0 0 0 +0.000 2000.000 +0ns 4000ms
ntp1.icolo.io 0 0 0 +0.000 2000.000 +0ns 4000ms
ntp0.icolo.io 0 0 0 +0.000 2000.000 +0ns 4000ms
If you want something that lets you see whether your software clock is being synchronized like the netstat
command shows, along with a lot more information concerning the software clock’s performance, try out the chronyc tracking
command.
Viewing software clock information via the chronyc tracking
command;
$ chronyc tracking
Reference ID : A29FC87B (time.cloudflare.com)
Stratum : 4
Ref time (UTC) : Sat May 22 07:17:34 2023
System time : 0.000392039 seconds fast of NTP time
Last offset : +0.000656034 seconds
RMS offset : 0.004044650 seconds
Frequency : 21.216 ppm slow
Residual freq : +0.002 ppm
Skew : 7.525 ppm
Root delay : 0.196831763 seconds
Root dispersion : 0.007088591 seconds
Update interval : 130.4 seconds
Leap status : Normal
In the above output, we obtain the following;
Reference ID
: The reference ID and name to which the computer is currently synced.Stratum
: Number of hops to a computer with an attached reference clock.Ref time
: This is the UTC time at which the last measurement from the reference source was made.System time
: Delay of system clock from synchronized server.Last offset
: Estimated offset of the last clock update.RMS offset
: Long term average of the offset value.Frequency
: This is the rate by which the system’s clock would be wrong if chronyd is not correcting it. It is provided in ppm (parts per million).Residual freq
: Residual frequency indicating the difference between the measurements from reference source and the frequency currently being used.Skew
: Estimated error bound of the frequency.Root delay
: Total of the network path delays to the stratum computer, from which the computer is being synced.Leap status
: This is the leap status which can have one of the following values – normal, insert second, delete second or not synchronized.
Conclusion
And that’s all about Managing Linux System Date and Time with UTC | Chrony | NTP. Stay tuned for more LPIC1 guides.
Similar Guides: