How to Set the Timezone and Configure NTP on Rocky Linux?
In today’s interconnected world, accurate timekeeping on your servers isn’t just a luxury — it’s a necessity. Whether you’re managing a small web server or a sprawling enterprise environment, setting the correct timezone and ensuring your system clock is synchronized with trusted time sources is critical. On Rocky Linux, a popular and stable enterprise-grade operating system, this process is both straightforward and essential for maintaining log accuracy, scheduled tasks, and system security.
This guide will walk you through the simple but crucial steps to set the timezone and configure NTP (Network Time Protocol) on Rocky Liltrnux. Whether you are preparing a brand-new server or tightening up an existing deployment, these configurations will ensure your system stays aligned with the world’s clocks and avoids the hidden pitfalls of time drift.
Prerequisites
- Before you start, make sure you:
- Have a Rocky Linux server (local or cloud-based)
- Can connect to it via SSH
Are logged in as a user with sudo privileges
Have updated your system:
Start by checking your current timezone and synchronization status:
timedatectl
Example output:
Local time: Sat 2022-04-02 00:44:18 UTC Universal time: Sat 2022-04-02 00:44:18 UTC RTC time: Sat 2022-04-02 00:44:17 Time zone: UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no
By default, Rocky Linux uses UTC. This is great for consistency across distributed systems, but you might want to change it to your local time for easier troubleshooting or regional operations.
Set the Timezone
To see the list of available timezones:
timedatectl list-timezones
Use the arrow keys to navigate, or type / to search. When you find your desired timezone, take note of the exact name (including capitalization). Press q to exit.
Let’s set it to the South Pole (just for fun):
sudo timedatectl set-timezone Antarctica/South_Pole
Verify the change:
cat /etc/timezone
You should see:
Antarctica/South_Pole
Check the current date and time again:
date
Example output:
Sat 02 Apr 2022 04:22:00 AM NZST
Want to switch back to UTC later? Just run:
sudo timedatectl set-timezone Etc/UTC
Enable and Verify NTP Time Sync
Rocky Linux uses systemd-timesyncd or Chrony to sync with NTP servers. First, let’s verify that it’s working:
timedatectl status
Example output:
Local time: Sat 2022-04-09 04:23:00 NZST Universal time: Fri 2022-04-08 16:23:00 UTC RTC time: Fri 2022-04-08 16:23:00 Time zone: Antarctica/South_Pole (NZST, +1200) System clock synchronized: yes NTP service: active RTC in local TZ: no
If the service isn’t active, turn it on:
sudo timedatectl set-ntp on
Give it a moment, then re-run timedatectl status to confirm.
View and Modify NTP Servers (Chrony)
Rocky Linux uses Chrony for time synchronization. Let’s check which NTP servers are configured.
cat /etc/chrony.conf
You’ll see something like:
server 1.time.constant.com iburst server 2.time.constant.com iburst server 3.time.constant.com iburst
To change these to public NTP servers, edit the configuration:
sudo nano /etc/chrony.conf
Replace the server lines with your preferred ones. For example, if you’re in the UK:
server 0.uk.pool.ntp.org iburst server 1.uk.pool.ntp.org iburst server 2.uk.pool.ntp.org iburst server 3.uk.pool.ntp.org iburst
Save and exit, then restart Chrony:
sudo systemctl restart chronyd
Check the current NTP sources:
chronyc sources
And confirm synchronization status:
chronyc tracking
Example output:
Reference ID : C3A8D0D2 (0.uk.pool.ntp.org) Stratum : 2 Ref time (UTC) : Fri Apr 08 00:18:17 2022 System time : 0.000303299 seconds fast of NTP time Last offset : +0.000142631 seconds RMS offset : 0.000152918 seconds Frequency : 6.807 ppm slow
(Optional) Set Up Your Server as an NTP Source
If you want to provide time sync to other systems (e.g., in a private network), you can turn your server into an NTP server.
Step 1: Allow Requests
Edit the Chrony config:
sudo nano /etc/chrony.conf
Add this line to allow clients from a private subnet:
allow 10.0.0.0/24
To allow any host (not recommended in production):
allow 0.0.0.0/0
Restart Chrony:
sudo systemctl restart chronyd
Step 2: Open the NTP Port
Allow NTP through the firewall:
sudo firewall-cmd --permanent --add-service=ntp sudo firewall-cmd --reload
Configure Clients to Use Your NTP Server
On each client machine, edit the Chrony config:
sudo nano /etc/chrony.conf
Add your NTP server’s IP address:
server 10.0.0.1 iburst
Restart Chrony:
sudo systemctl restart chronyd
Check if the client is syncing:
chronyc sources chronyc tracking
On your server, check which clients are connected:
chronyc clients
Example output:
Hostname NTP Drop Int IntL Last Cmd Drop Int Last =============================================================================== 10.0.0.1 2 0 6 - 8 0 0 - -
Wrapping Up
Configuring the correct timezone and setting up reliable NTP synchronization may seem like a small detail, but it forms the backbone of a well-managed Rocky Linux system. From debugging issues to keeping secure transactions properly timestamped, accurate timekeeping influences nearly every aspect of server operation.
By following these steps, you’ve not only aligned your server with the correct timezone but also ensured it remains consistently accurate, no matter where it’s deployed. With time on your side, your Rocky Linux system is better equipped to handle the demands of modern computing — reliably, securely, and precisely.