• Posted: 28-07-2023
  • Last Updated: 28-07-2025
  • Category: Server Guides

Synchronizing time and setting the correct timezone for your server is a basic but extremely important configuration step. This article will guide you on how to accurately set the Vietnam timezone (GMT+7) for your Linux server.

Why is Time Synchronization Important?

Accurate system time is a mandatory requirement for many tasks:

  • Log Analysis: Helps you track event logs accurately in chronological order.
  • Cron Job Scheduling: Ensures that automated tasks are executed at the correct scheduled time.
  • Application Functionality: Many applications, especially those requiring authentication or transactions, depend on accurate timestamps.
  • Security: Helps validate SSL certificates and other time-based security protocols.

Method 1: Using timedatectl (Recommended)

On modern operating systems (CentOS 7+, Ubuntu 16+, Debian 8+), timedatectl is the standard and recommended tool for managing system time. It is simpler and safer than the traditional method.

  • Step 1: Check the Current Timezone

    Open a terminal and run the following command to see the server's current time settings.

    timedatectl

    You will see output similar to this:

    Local time: Wed 2025-07-16 03:48:59 UTC
    Universal time: Wed 2025-07-16 03:48:59 UTC
    RTC time: Wed 2025-07-16 03:48:59
    Time zone: Etc/UTC (UTC, +0000)
    System clock synchronized: yes
    systemd-timesyncd.service active: yes
    RTC in local TZ: no
  • Step 2: Set the Vietnam Timezone

    Execute the following command to change the system's timezone to Asia/Ho_Chi_Minh.

    sudo timedatectl set-timezone Asia/Ho_Chi_Minh
  • Step 3: Enable Network Time Protocol (NTP) Synchronization

    To ensure the system clock is always accurate, enable the NTP service. This service will automatically synchronize your server's time with time servers around the world.

    sudo timedatectl set-ntp true
  • Step 4: Verify the Changes

    Run the timedatectl command again to make sure the timezone has been changed and NTP is active.

    timedatectl

    The "Time zone" line will now show Asia/Ho_Chi_Minh (GMT+7).

Method 2: Using the ln Command (Traditional Way)

This is an older method that still works on most Linux systems. The steps below are similar to your original guide but include time synchronization using chrony (which replaces the outdated rdate).

  • Step 1: Back up and Create the Timezone Symlink
    # Back up the old localtime file
    sudo mv /etc/localtime /etc/localtime.old

    # Create a symbolic link to the Asia/Ho_Chi_Minh timezone file
    sudo ln -sf /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtime
  • Step 2: Synchronize Time with Chrony

    Chrony is the default NTP service on RHEL/CentOS 7+ distributions.

    # Install Chrony (if not already installed)
    # On CentOS/RHEL:
    sudo yum install -y chrony
    # On Ubuntu/Debian:
    sudo apt-get install -y chrony

    # Start and enable the Chrony service
    sudo systemctl start chronyd
    sudo systemctl enable chronyd

    # Force an immediate time synchronization
    sudo chronyc makestep

Conclusion

Using timedatectl is the highly recommended method due to its simplicity, safety, and consistency across modern operating systems. Whichever method you choose, ensure your server is always running on the correct timezone and is time-synchronized for stable and accurate operation.

Share:
Rating:

( Total: 1 ratings. Average 5, scale: 1 to 5 )