This article will demonstrate how to manage Ubuntu time settings. The examples provided in this article were completed with Ubuntu 20.04.4 LTS, but should work for any recent version of Ubuntu. If not, leave us a comment and we will update accordingly.
To check your version of Ubuntu, run the following command:
lsb_release -aIn this case, the result is:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focalUbuntu Timezones
For some apparent reason you have discovered the time on your Ubuntu server is not correct. Either it is entirely incorrect or just in another time zone. You may have discovered the time was off if you troubleshoot logs or use dates in any way that later do not line up with what you are expecting. It’s common to find the time set to UTC time, but you may want it set to your local time zone instead. This example will demonstrate how to set your time zone to ET (encompassing EST and EDT).
If you haven’t already, run the date command to show your current time.
dateIn this case the result was:
Wed Jun 15 10:41:56 EDT 2022To display the list of time zones in Ubuntu, run the following command:
timedatectl list-timezonesChoose the time zone local to you and set it with the following command. In this case for ET, EST, or EDT, it is the America/New_York timezone.
timedatectl set-timezone America/New_YorkNow run the date command again to ensure the Ubuntu time zone has synced.
Ubuntu time sync
To display the time sync settings in Ubuntu, use the systemd-timesyncd status by running the following command:
systemctl status systemd-timesyncdYou may wish to sync with a different NTP server than configured by default. To do so, modify the /etc/systemd/timesyncd.conf file by uncommenting the NTP and FallbackNTP properties and changing them to your desired settings. ntp.ubuntu.com is the default NTP server sync for Ubuntu, so we decided to leave that as the fallback in this case.
# 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=your.ntp.com
FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048Save the file and restart the systemd-timesyncd process.
service systemd-timesyncd restartDisplay the systemd-timesyncd status again to show the updated NTP settings.
Conclusion
There you have it. The examples above have demonstrated how to manage Ubuntu time settings including how to sync Ubuntu time with an NTP server as well as change the time zone. Let us know in the comments if you would like to see additional examples of Ubuntu time settings or if you have any questions. Check out our other articles.
Leave a Reply