How to Setup the Date Timezone and NTP for Ubuntu 22.04 LTS

Check TimeZone

  • Check Current TimeZone and NTP Status
timedatectl
ubuntu@NUC-TM:~$ timedatectl
               Local time: ส. 2022-09-10 01:36:47 +07
           Universal time: ศ. 2022-09-09 22:36:47 UTC
                 RTC time: จ. 2009-01-19 04:10:25
                Time zone: Asia/Istanbul(+03, +0300)
System clock synchronized: no
              NTP service: n/a
          RTC in local TZ: no
  • Checking the list of available time zones
timedatectl list-timezones
  • you can use the grep command to limit the result
timedatectl list-timezones | grep -i bangkok
  • Changing the time zone
sudo timedatectl set-timezone Asia/Bangkok
  • Check TimeZone and NTP Status

Setup NTP Service

  • Test Enable NTP
sudo timedatectl set-ntp on

> Failed to set ntp: NTP not supported
  • If system tell "Failed to set ntp: NTP not supported". You need to install systemd-timesyncd
sudo apt-get update
sudo apt install systemd-timesyncd
  • Activate NTP and Enter your admin password for time synchronization
timedatectl set-ntp true
  • Check Current TimeZone and NTP Status
timedatectl

Enabling/Disabling time synchronization

  • Enable time synchronization. >> Set NTP Service active
sudo timedatectl set-ntp on
  • Disable time synchronization. >> Set NTP Service inactive
sudo timedatectl set-ntp off

Case time does not sync

  • check service status
systemctl status systemd-timesyncd
  • the root cause is a network issue (time out to connect NTP server)
  • After fixing network issue, restart the service and check service systemd-timesyncd status
systemctl restart systemd-timesyncd

Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.