To ensure your business records accurate logs, you’ll want to work on your timekeeping synchronization. Time synchronization will also come in handy when you want to update your database or debug issues related to data corruption or errors. In this post, we will guide you on how to configure your Ubuntu 22.04 time sync.
What is Ubuntu?
Ubuntu is a free and open-source software designed for computers, smartphones, and network servers. It’s widely used for personal purposes but can be used to run an organization, school, home, or business.
Why choose Ubuntu?
Ubuntu is not just a popular operating system for nothing. It has a lot to offer. Here are some reasons to choose Ubuntu.
- It’s free: Downloading, using, and sharing Ubuntu is free.
- High-security Ubuntu comes with a built-in firewall and virus protection software to protect you and your programs.
- Great features: Ubuntu comes with all the essential applications you might need, from an office suite, email, browsers, and media apps.
- Accessibility: Ubuntu is available in 50 different languages and has essential assistive technologies.
Requirements
Here’s what you need to get started with Ubuntu:
- CPU: 1 gigahertz or better
- 2.5 gigabytes disk or more
- 1 gigabyte RAM or more
- Server with stable internet access
- Server with Sudo privileges
- An operating system running Ubuntu 22.04 server with a non-root administrative user
How to Configure Ubuntu time sync
Follow the following steps to set up time synchronization in Ubuntu:
The most commonly used time command on Ubuntu 18.04 is the date command. This command is used to check the time and date on an Ubuntu server:
The timedatetecl command allows you to both query and change the system clock and its settings on Linux systems.
To display the current settings, use the command by itself with no arguments. You should get something like this:
Common Time Zones:
A few examples of Europe:
US
Time and date changes are seldom needed since your system generally manages this from the time of installation using NTP. If you move or take your laptop on vacation with you, however, you might want to make some changes to accommodate your new location.
To change your settings, you need to use Sudo. However, sudo is only needed if your session is not with a privileged user.
If you try to change the timezone with a non-privileged user without sudo, you receive an error:
With sudo:
$ sudo timedatectl set-timezoneAmerica/New_York
This will change your time zone to America/New_York. To check if this time zone was properly implemented, execute the command below:
$ sudo date
This will give you the output below:
SunOct 28 12:18:59 EDT 2018
To check the time sync status on your Ubuntu 18.04 system, run the command below
$ sudo timedatectl
This will give you the following output:
The value YES for the System clock synchronized proves that time is correctly synced, and the YES for the system time synced. Service actively indicated that time synced has been enabled and is running properly. In case the time synced is inactive, run the command below to turn it on;
$ sudo timedatectl set-ntpon
Once you enable time synced, execute the ttimedatectl to check the status of the network time.
A SPACE MUST EXISTS AFTER SET-NTP (set-ntp on)
With man timedatectl, we can check the help of the command.
So we can enable or disable it at will by launching:
timedatectl set-NTP on (enabled) timedatectl set-ntp off (disabled)
We can check the NTP status with the following command:
timedatectl (we actÃvate it and check, and then disable and check again to see how it changes)
timedatectl set-ntp on.
timedatectl set-ntp off
CHANGING TO NTPD:
We will install NTP, and it will automatically disable the system-time sync service. We will be able to use NTPQ to query our sync status; if we try to use it before switching to NTPD, we will receive the following error:
So we proceed to install NTPD:
Confirm installation with “y.â€
Now, we can not use the aforementioned commands of timedatectl:
This is because now we are using NTPD and not time synced, which has been masked and disabled:
Instead of timedatectl, now we can use ntpq (NTP Query) with the following arguments:
-pn
So, the ntpq –pn command returns:
This is what each column means:
Remote: Hostname or IP address of the time source used
Refid: where the remote server mentioned above obtains the time from
st: The stratum of the source (16 means the source is not in sync or unreachable)
t: the type of the time source. A few examples could be: 1 for a local hardware reflock, or u for an NTP server that has been accessed via unicast protocol
When: This is the time in which the last poll event took place. When this field reaches the pool value is when the next polling action takes place.
Poll: in seconds, the current polling interval
Reach: octal representation of the field reach status.
Delay: in milliseconds: the mean of the time needed to reach and receive a response from the time source
Offset: in milliseconds, the mean of the time offset
Jitter: in milliseconds, and indicator of variance of the packet delays from individual pollings.
NTPD uses port 123 UDP
Conclusion
Replacing your current operating system with Ubuntu and configuring time is an uneasy process whether you’re using Windows or macOS or running Ubuntu alongside it.
If you follow the above steps, you’ll be able to configure Ubuntu 22.04 fast and easily.
Next Steps: What Now?
Here are some practices that cut through this guide:
- Download and install Ubuntu
- Create a database on Ubuntu
- Use the date command to check the date and time on the Ubuntu server.
- Use sudo to change the date and time settings.
Further Reading
If you want to learn more about Ubuntu and Ubuntu time synchronization, here are some of our resources that will help guide you.
- https://hostadvice.com/how-to/how-to-setup-the-date-and-timezone-on-an-ubuntu-22-04-vps-or-dedicated-server/#paragraph6
- https://hostadvice.com/how-to/how-to-install-mysql-on-ubuntu/