GNU Linux (obecně)

Last modified by bac0025 on 29.08.2017 12:43

Nejprve si pod uživatelem pro správu správně nastavte časovou zónu (ukázka změny na časovou zónu Europe/Prague):

# tzconfig 
 Your current time zone is set to Africa/Abidjan
 Do you want to change that? [n]: y 

 Please enter the number of the geographic area in which you live: 

1) Africa7) Australia
2) America8) Europe
3) US time zones9) Indian Ocean
4) Canada time zones10) Pacific Ocean
5) Asia11) Use System V style time zones
6) Atlantic Ocean 12) None of the above

Then you will be shown a list of cities which represent the time zone in which they are located. You should choose a city in your time zone.

Number: 8
Amsterdam Andorra Athens Belfast Belgrade Berlin Bratislava Brussels
Bucharest Budapest Chisinau Copenhagen Dublin Gibraltar Guernsey Helsinki
Isle_of_Man Istanbul Jersey Kaliningrad Kiev Lisbon Ljubljana London
Luxembourg Madrid Malta Mariehamn Minsk Monaco Moscow Nicosia Oslo Paris
Podgorica Prague Riga Rome Samara San_Marino Sarajevo Simferopol Skopje
Sofia Stockholm Tallinn Tirane Tiraspol Uzhgorod Vaduz Vatican Vienna
Vilnius Volgograd Warsaw Zagreb Zaporozhye Zurich 

Please enter the name of one of these cities or zones
You just need to type enough letters to resolve ambiguities
Press Enter to view all of them again

Name: [] Prague
Your default time zone is set to 'Europe/Prague'.
Local time is now:      Tue Nov  6 07:55:25 CET 2007.
Universal Time is now:  Tue Nov  6 06:55:25 UTC 2007.

V závislosti na správci balíčkového systému nainstalujeme potřebný balíček ntpdate (ukázka pro Ubuntu/Debian):

 # apt-get install ntpdate
 Reading package lists... Done
 Building dependency tree... Done
 The following NEW packages will be installed:
 ntpdate
 0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
 Need to get 57.7kB of archives.
 After unpacking 213kB of additional disk space will be used.
 Get:1 http://ftp.dk.debian.org etch/main ntpdate 1:4.2.2.p4+dfsg-2 [57.7kB]
 Fetched 57.7kB in 10s (5475B/s)
 Selecting previously deselected package ntpdate.
 (Reading database ... 23025 files and directories currently installed.)
 Unpacking ntpdate (from .../ntpdate_1%3a4.2.2.p4+dfsg-2_i386.deb) ...
 Setting up ntpdate (4.2.2.p4+dfsg-2) ...

Aktuální čas systému:

 # date 
 Sun Nov  4 12:27:06 CET 2007

Pro synchronizaci času s našim ntp serverem použijeme program ntpdate takto:

 # ntpdate ntp1.vsb.cz
 4 Nov 10:46:39 ntpdate[2218]: step time server 158.196.0.2 offset -6072.831130 sec

Aktuální čas systému (po synchronizaci):

 # date 
 Sun Nov  4 10:46:52 CET 2007 

V případě, že je náš server nedostupný, vypíše se toto oznámení:

# ntpdate ntp2.vsb.cz 
 4 Nov 12:27:38 ntpdate[2219]: no server suitable for synchronization found 

Pro pravidelnou synchronizaci času přidáme do Cronu (/etc/crontab) tento řádek: 

 1 *     * * *   root    /usr/sbin/ntpdate ntp1.vsb.cz >/dev/null 2>&1