The Network Time Protocol (NTP) is a protocol for synchronizing the clocks of computer systems over packet-switched, variable-latency data networks.
NTP provides Coordinated Universal Time (UTC). No information about time zones or daylight saving time is transmitted; this information is outside its scope and must be obtained separately. In isolated LANs, NTP could in principle be used to distribute a different time scale (e.g. local zone time), but this is uncommon
ntpdate is a computer program used to synchronize and set computers’ date and time by polling the Network Time Protocol (NTP) server(s).
The accuracy and reliability of ntpdate depends on the number of servers, the number of polls each time it is run and the interval between runs.
Task 1 : Update system time
ntpdate ntp.ubuntu.com pool.ntp.org
This command will update your linux system time (need root account):
laptop:~# ntpdate ntp.ubuntu.com pool.ntp.org
11 Oct 22:59:09 ntpdate: adjust time server 18.104.22.168 offset 0.023347 sec
Task 2 : Check a ntpd server
ntpdate -d ntp1.inrim.it
With the option -d (debug) you can check the reachability of a ntpd server and test a synchronization.
laptop:~# ntpdate -d ntp1.inrim.it
11 Oct 23:52:07 ntpdate: ntpdate [email protected] Fri Aug 6 22:49:55 UTC 2010 (1)
Looking for host ntp1.inrim.it and service ntp
host found : ntp1.inrim.it
server 22.214.171.124, port 123
stratum 1, precision -18, leap 00, trust 000
refid [CTD], delay 0.06894, dispersion 24.00008
transmitted 4, in filter 4
reference time: d05e057c.f022abbe Mon, Oct 11 2010 23:51:56.938
originate timestamp: d05e0588.eb4fd0e9 Mon, Oct 11 2010 23:52:08.919
transmit timestamp: d05e0588.e929dc72 Mon, Oct 11 2010 23:52:08.910
filter delay: 0.06953 0.00000 0.06894 0.00000
0.00000 0.00000 0.00000 0.00000
filter offset: 0.029989 0.000000 0.030154 0.000000
0.000000 0.000000 0.000000 0.000000
delay 0.06894, dispersion 24.00008
11 Oct 23:52:09 ntpdate: adjust time server 126.96.36.199 offset 0.030154 sec
The ntpd program is an operating system daemon that sets and maintains the system time in synchronization with Internet standard time servers. The ntpd program normally operates continuously while adjusting the system time and frequency.
Ntpd daemon use (usually) as configuration file /etc/ntp.conf
Installing on ubuntu with the command
aptitude install ntp you’ll have a working configuration file and after the install the daemon will be started.
Some explanation on the configuration
# You do need to talk to an NTP server or two (or three).
The server directive indicate the ntp servers to be used to get an update about time, in your company ask to the peoples in charge of the network, usually routers or other network devices are used as ntp server.
With the directive driftfile you can specify a file to store the frequency correction applied to the local clock to be put it in sync with the UTC, to make faster the synchronization process after a restart of the daemon ntpd.
If this file is defined, the daemon ntpd use as the initial correction frequency of the value found in the file, otherwise use the value 0.
Some useful commands.
Task 3: Check if ntpd is running
Verify if Network Time Protocol daemon is working properly
laptop:~# ntpq -p
remote refid st t when poll reach delay offset jitter
*europium.canoni 188.8.131.52 2 u 50 64 377 71.416 28.190 22.704
If the symbol * left an address, it means that the time is taken by the respective server, if there isn’t any * it means that we’re not aligned with any server.
NTPDATE or NTP ?
ntpdate can be run manually as necessary to set the host clock, or it can be run from the host startup script to set the clock at boot time. This is useful in some cases to set the clock initially before starting the NTP daemon ntpd. It is also possible to run ntpdate from a cron script. However, it is important to note that ntpdate with contrived cron scripts is no substitute for the NTP daemon, which uses sophisticated algorithms to maximize accuracy and reliability while minimizing resource use. Finally, since ntpdate does not discipline the host clock frequency as does ntpd, the accuracy using ntpdate is limited.
Hwclock is a program that runs under Linux and sets and queries the Hardware Clock, which is often called the Real Time Clock, RTC, or CMOS clock. This is the program that most Linux systems use to get the time from the Hardware Clock and set the System Time at boot time.
Task 4: Query the hardware clock
This command show the actual hardware clock of the computer.
laptop:~# hwclock -r
Tue 12 Oct 2010 12:19:18 AM CEST -0.348773 seconds
Task 5: Adjust both system and hardware clock
ntpdate pool.ntp.org && hwclock --systohc && hwclock --adjust
With this command you first synchronize your system clock with ntpdate and than with hwclock –systohc you also sinc the hardwareclock.
laptop:~# ntpdate pool.ntp.org && hwclock --systohc && hwclock --adjust
12 Oct 00:25:23 ntpdate: adjust time server 184.108.40.206 offset 0.068321 sec
For more info check also http://ntp.org/
- Linux Terminal: speedtest_cli checks your real bandwidth speed.
- Zorin OS 9 Core Review: As good as Linux Mint 17!
- How to reboot Linux automatically on Kernel Panic
- Linux AIO some of the most common distributions in one ISO
- How to share on linux the output of your shell commands
Find me on Google+