Ubuntu

ubuntu Server 20.04.3 LTS 時刻同期

ubuntu Server 20.04.3 LTSで時刻同期設定を変更する。


①デフォルトの時刻設定を使用する。

デフォルトでは、systemd-timesyncdにより時刻同期が行われているようなのでconfを修正。

筆者環境ではイントラ内のエッジルーターをNTPマスターとしているので参照先をそちらに変更する。(15行目のコメントを外してエッジルーターのIPアドレスを指定)

#  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=192.168.11.1
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048

デーモンをrestartして同期先と状態を確認。

NTPSynchronized=yes、NTP service: active になってればOK。

$ sudo systemctl restart systemd-timesyncd
$ 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 Sun 2022-02-13 00:07:32 JST; 23min ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 2562 (systemd-timesyn)
     Status: "Initial synchronization to time server 192.168.11.1:123 (192.168.11.1)."
      Tasks: 2 (limit: 1066)
     Memory: 1.1M
     CGroup: /system.slice/systemd-timesyncd.service
             mq2562 /lib/systemd/systemd-timesyncd

Feb 13 00:07:32 svubuntub01 systemd[1]: Starting Network Time Synchronization...
Feb 13 00:07:32 svubuntub01 systemd[1]: Started Network Time Synchronization.
Feb 13 00:07:32 svubuntub01 systemd-timesyncd[2562]: Initial synchronization to time server 192.168.11.1:123 (192.168.11.1).
$
$ timedatectl status
               Local time: Sun 2022-02-13 00:28:45 JST
           Universal time: Sat 2022-02-12 15:28:45 UTC
                 RTC time: Sat 2022-02-12 15:28:44
                Time zone: Asia/Tokyo (JST, +0900)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
$
$ timedatectl show
Timezone=Asia/Tokyo
LocalRTC=no
CanNTP=yes
NTP=yes
NTPSynchronized=yes
TimeUSec=Sun 2022-02-13 00:28:01 JST
RTCTimeUSec=Sun 2022-02-13 00:28:01 JST

以上。