So, we have the task of synchronizing time on our Linux machine.
To do this, we install NTP and configure it:
$ sudo aptitude install ntp ntpdate
Now we head to /etc and open the ntp.conf file. We check that the servers NTP will get the time from are listed there:
...
# pool.ntp.org maps to about 1000 low-stratum NTP servers. Your server will
# pick a different set every time it starts up. Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
server 0.debian.pool.ntp.org iburst dynamic
server 1.debian.pool.ntp.org iburst dynamic
server 2.debian.pool.ntp.org iburst dynamic
server 3.debian.pool.ntp.org iburst dynamic
...
We start NTPd:
$sudo /etc/init.d/ntpd start
From now on the computer will start synchronizing the time on its own. The service adds itself to autostart on Debian automatically.
Running ntpd manuallyThe daemon can also be run manually, for example, via cron. For this the "-q" flag is used — with it, the daemon starts up, synchronizes the time, and exits immediately:
$sudo ntpd -q
ntpdateThis is a command-line utility for managing NTP. It lets you synchronize the time manually — essentially the equivalent of "ntpd -q". As its parameter it takes the FQDN of the server to synchronize with.
$sudo ntpdate 0.debian.pool.ntp.org
Comments