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

Synchronizing time and setting the correct timezone for your server is a basic but extremely important configuration step. Accurate system time affects log analysis, cron job scheduling, and the functionality of many applications.

This article will guide you on how to accurately set the Vietnam timezone (GMT+7) for your Linux server.

Table of Contents

1. 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.

2. Using timedatectl (Method 1 - 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: Fri 2025-08-08 05:13:06 UTC
    Universal time: Fri 2025-08-08 05:13:06 UTC
    RTC time: Fri 2025-08-08 05:13:06
    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 (ICT, +0700).

3. Using the ln Command (Method 2 - Traditional)

This is an older method that still works on most Linux systems. It requires an additional manual step for time synchronization using Chrony.

  • 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

4. 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 Vietnam timezone and is time-synchronized for stable and accurate operation.

All KVM VPS and Dedicated Server services at VietHosting are pre-configured with the Vietnam timezone for customer convenience.

Share:
Rating:

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