How to Permanently Set Timezone in Ubuntu (Fix NTP Override Issues)


2 views

Many Ubuntu users encounter a frustrating situation where manually set timezone configurations don't persist after system reboots or NTP synchronizations. The system keeps reverting to UTC despite correct tzselect output showing the proper local time.

Modern Ubuntu systems use multiple time management components:

1. systemd-timedated (primary time manager)
2. timedatectl (command-line interface)
3. tzdata (timezone database)
4. NTP service (chrony/systemd-timesyncd)

Method 1: Using timedatectl (Recommended)

sudo timedatectl set-timezone Europe/London
sudo timedatectl set-local-rtc 1 --adjust-system-clock

Method 2: Manual Symlink Creation

sudo ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime
sudo dpkg-reconfigure -f noninteractive tzdata

To prevent NTP from overriding your timezone settings:

# For systemd-timesyncd:
sudo timedatectl set-ntp false

# For chrony:
sudo systemctl stop chrony
sudo systemctl disable chrony

Check all relevant time settings with:

timedatectl status
cat /etc/timezone
ls -l /etc/localtime
systemctl status systemd-timedated

If problems persist, examine logs:

journalctl -u systemd-timedated -b
journalctl -u chronyd -b

For cloud servers or containers, add this to your provisioning:

RUN echo "Europe/London" > /etc/timezone \\
    && ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime \\
    && dpkg-reconfigure -f noninteractive tzdata

When dealing with time management on Ubuntu servers, many administrators encounter situations where manually set timezones (like Europe/London) appear correct in configuration but don't persist across reboots or NTP synchronizations. The fundamental issue stems from multiple time management systems interacting:

# What shows as configured
$ timedatectl
               Local time: Thu 2023-11-02 12:00:00 UTC
           Universal time: Thu 2023-11-02 12:00:00 UTC
                 Timezone: Europe/London (UTC, +0000)
System clock synchronized: yes
              NTP service: active

Modern Ubuntu versions use systemd's timedatectl for time management. The proper way to set timezone permanently:

# 1. List available timezones
$ timedatectl list-timezones | grep -i london

# 2. Set the timezone permanently
$ sudo timedatectl set-timezone Europe/London

# 3. Verify the change
$ timedatectl

When NTP keeps resetting your time to UTC despite timezone settings:

# Check current NTP configuration
$ cat /etc/systemd/timesyncd.conf

# Edit the config to ensure proper timezone handling
[Time]
NTP=pool.ntp.org
FallbackNTP=ntp.ubuntu.com
# Important: Set your timezone source
Timezone=Europe/London

For systems not using systemd or needing deeper control:

# Symlink method (older Ubuntu versions)
$ sudo rm -f /etc/localtime
$ sudo ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

# Verify with
$ date

When changes don't take effect:

# Restart time synchronization services
$ sudo systemctl restart systemd-timesyncd

# Force immediate time update
$ sudo timedatectl set-ntp true
$ sudo systemctl daemon-reload

# Check service status
$ sudo systemctl status systemd-timesyncd

Cloud environments often need additional configuration:

# Create /etc/cloud/cloud.cfg.d/99_timezone.cfg
# With contents:
preserve_hostname: true
timezone: Europe/London

# Then run
$ sudo dpkg-reconfigure -f noninteractive tzdata