


Ubuntu 20の時刻合わせ
How To Set Up Time Synchronization on Ubuntu 20.04
https://www.digitalocean.com/community/tutorials/how-to-set-up-time-synchronization-on-ubuntu-20-04
Ubuntu 20.04の時刻合わせはtimesyncd serviceが標準でインストールされて有効化されていると。
設定ファイルは/etc/systemd/timesyncd.conf
- 標準設定
- ntp.jst.mfeed.ad.jpで同期設定
- systemd-timesyncdの再起動
- 確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
rootlinks@ubuntu20:~$ sudo cat /etc/systemd/timesyncd.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Entries in this file show the compile time defaults. # You can change settings by editing this file. # Defaults can be restored by simply deleting this file. # # See timesyncd.conf(5) for details. [Time] #NTP= #FallbackNTP=ntp.ubuntu.com #RootDistanceMaxSec=5 #PollIntervalMinSec=32 #PollIntervalMaxSec=2048 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
rootlinks@ubuntu20:~$ sudo vi /etc/systemd/timesyncd.conf rootlinks@ubuntu20:~$ sudo cat /etc/systemd/timesyncd.conf # This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # Entries in this file show the compile time defaults. # You can change settings by editing this file. # Defaults can be restored by simply deleting this file. # # See timesyncd.conf(5) for details. [Time] NTP=ntp.jst.mfeed.ad.jp #FallbackNTP=ntp.ubuntu.com #RootDistanceMaxSec=5 #PollIntervalMinSec=32 PollIntervalMaxSec=86400 |
1 |
rootlinks@ubuntu20:~$ sudo systemctl restart systemd-timesyncd |
“Initial synchronization to time server 210.173.160.57:123 (ntp.jst.mfeed.ad.jp).”と表示されてます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
rootlinks@ubuntu20:~$ sudo systemctl status systemd-timesyncd ● systemd-timesyncd.service - Network Time Synchronization Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2022-01-12 19:53:20 JST; 1min 4s ago Docs: man:systemd-timesyncd.service(8) Main PID: 48640 (systemd-timesyn) Status: "Initial synchronization to time server 210.173.160.57:123 (ntp.jst.mfeed.ad.jp)." Tasks: 2 (limit: 9467) Memory: 1.2M CGroup: /system.slice/systemd-timesyncd.service └─48640 /lib/systemd/systemd-timesyncd Jan 12 19:53:20 ubuntu20.example.jp systemd[1]: Starting Network Time Synchronization... Jan 12 19:53:20 ubuntu20.example.jp systemd[1]: Started Network Time Synchronization. Jan 12 19:54:21 ubuntu20.example.jp systemd-timesyncd[48640]: Initial synchronization to time server> |
1 2 3 4 5 6 7 8 |
rootlinks@ubuntu20:~$ timedatectl status Local time: Wed 2022-01-12 19:53:33 JST Universal time: Wed 2022-01-12 10:53:33 UTC RTC time: Wed 2022-01-12 10:53:34 Time zone: Asia/Tokyo (JST, +0900) System clock synchronized: yes NTP service: active RTC in local TZ: no |
manを見ても設定が簡単ですが最初の同期でいっきに時刻を合わせるんですかね。
上記のサイトには場合によってはntpdを使うこともできると。
timesyncd will work in most circumstances. There are instances, however, when an application may be sensitive to any disturbance with time. In this case, ntpd is an alternative network time service you can use. ntpd uses sophisticated techniques to constantly and gradually keep the system time on track.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
TIMESYNCD.CONF(5) timesyncd.conf TIMESYNCD.CONF(5) NAME timesyncd.conf, timesyncd.conf.d - Network Time Synchronization configuration files SYNOPSIS /etc/systemd/timesyncd.conf /etc/systemd/timesyncd.conf.d/*.conf /run/systemd/timesyncd.conf.d/*.conf /usr/lib/systemd/timesyncd.conf.d/*.conf DESCRIPTION These configuration files control NTP network time synchronization. See systemd.syntax(7) for a general description of the syntax. CONFIGURATION DIRECTORIES AND PRECEDENCE The default configuration is defined during compilation, so a configuration file is only needed when it is necessary to deviate from those defaults. By default, the configuration file in /etc/systemd/ contains commented out entries showing the defaults as a guide to the administrator. This file can be edited to create local overrides. When packages need to customize the configuration, they can install configuration snippets in /usr/lib/systemd/*.conf.d/ or /usr/local/lib/systemd/*.conf.d/. The main configuration file is read before any of the configuration directories, and has the lowest precedence; entries in a file in any configuration directory override entries in the single configuration file. Files in the *.conf.d/ configuration subdirectories are sorted by their filename in lexicographic order, regardless of in which of the subdirectories they reside. When multiple files specify the same option, for options which accept just a single value, the entry in the file with the lexicographically latest name takes precedence. For options which accept a list of values, entries are collected as they occur in files sorted lexicographically. Files in /etc/ are reserved for the local administrator, who may use this logic to override the configuration files installed by vendor packages. It is recommended to prefix all filenames in those subdirectories with a two-digit number and a dash, to simplify the ordering of the files. To disable a configuration file supplied by the vendor, the recommended way is to place a symlink to /dev/null in the configuration directory in /etc/, with the same filename as the vendor configuration file. OPTIONS The following settings are configured in the "[Time]" section: NTP= A space-separated list of NTP server host names or IP addresses. During runtime this list is combined with any per-interface NTP servers acquired from systemd- networkd.service(8). systemd-timesyncd will contact all configured system or per-interface servers in turn until one is found that responds. When the empty string is assigned, the list of NTP servers is reset, and all assignments prior to this one will have no effect. This setting defaults to an empty list. FallbackNTP= A space-separated list of NTP server host names or IP addresses to be used as the fallback NTP servers. Any per-interface NTP servers obtained from systemd- networkd.service(8) take precedence over this setting, as do any servers set via NTP= above. This setting is hence only used if no other NTP server information is known. When the empty string is assigned, the list of NTP servers is reset, and all assignments prior to this one will have no effect. If this option is not given, a compiled-in list of NTP servers is used instead. RootDistanceMaxSec= Maximum acceptable root distance. Takes a time value (in seconds). Defaults to 5 seconds. PollIntervalMinSec=, PollIntervalMaxSec= The minimum and maximum poll intervals for NTP messages. Each setting takes a time value (in seconds). PollIntervalMinSec= must not be smaller than 16 seconds. PollIntervalMaxSec= must be larger than PollIntervalMinSec=. PollIntervalMinSec= defaults to 32 seconds, and PollIntervalMaxSec= defaults to 2048 seconds. SEE ALSO systemd(1), systemd-timesyncd.service(8), systemd-networkd.service(8) systemd 245 TIMESYNCD.CONF(5) |