
Accurate time is essential for any production server and the Network Time Protocol (NTP) is the standard way to keep the system clocks synchronized to accurate sources. NTP uses the intersection algorithm to mitigate the effects of variable network latency and keep your system clock within a few milliseconds of Coordinated Universal Time (UTC). Linux systems typically keep the time in UTC, but you can also set the timezone to your local timezone. This article explains how to set the timezone on an Ubuntu Linux cloud server and use NTP to synchronize the time.
To check your current timezone, log in to your server and display the date and time.
You'll see output similar to this:
By default, a Vultr Rocky Linux server uses the UTC timezone, which is usually preferable if you manage servers in different locations. However, you can set the server to your local timezone by following these steps.
View a list of all timezones.
Select your desired timezone and take note of the exact name and capitalization. You can use Space and B to page forward and backward or your arrow keys to move one line at a time through the list. When finished, type Q to exit the list.
For this example, choose Antarctica/South_Pole.
Set the timezone with timedatectl.
Verify the timezone by viewing /etc/timezone.
Check the time to verify the changes.
Notice the timezone now shows NZST, indicating the time at the South Pole.
If you decide to return to UTC later, run timedatectl again with the UTC timezone.
Vultr's Rocky Linux systems have the timesyncd service enabled by default to synchronize their time with an NTP server. You can verify this by running timedatectl.
The System clock synchronized: yes and NTP service: active lines confirm that the system clock has synchronized with an NTP server. If you see these, you can proceed to the next section. Otherwise, start the service with timedatectl. Again, you need to be the root user or use sudo.
Wait a few minutes for the timesyncd service to start, then verify the status.
Vultr configures new servers with constant.com NTP servers, which are low-latency servers on Vultr's network infrastructure. You can examine the configuration by viewing chrony.conf.
You'll see the default NTP servers:
If you need to use specific NTP servers:
Edit the Chrony configuration file.
Change them according to your needs. You'll find public name servers listed on the NTP support website.. For example, if you want to sync with the public UK pool, you can use the following values:
Restart the Chrony NTP daemon to load changes.
Verify the new NTP pools.
Confirm the NTP synchronization status.
Most users do not need to set up an NTP server. However, in some situations, you may want to offer NTP service, perhaps to a Virtual Private Cloud (VPC). If you know that you need an NTP server, follow these steps.
To accept client requests to the server:
Edit the main Chrony configuration file.
Add a line to allow requests from the desired network interface, such as a VPC network address.
To allow connections from all interfaces, use the
Allow 0.0.0.0/0directive.
Save and close the file.
Restart Chrony to load changes.
To accept incoming client requests, allow the NTP service through the firewall.
Restart the Firewall.
On each client that should receive time from your NTP server:
Edit the configuration file.
Add a line specifying your NTP time server's IP address. For example:
Restart the Chrony NTP daemon to load changes.
Show available NTP sources:
Verify the NTP synchronization status.
Output:
From your NTP server, confirm the clients have connected by running the following command:
Output:
You have set up the timezone and configured NTP on Rocky Linux. For more information, please see these resources:
0 Comments
Be the first to comment and share your perspective with the community.