You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
ECS instance local time synchronization
Configuring NTP service for Linux instances (Ubuntu 18)
Copy page
Download PDF
Configuring NTP service for Linux instances (Ubuntu 18)
This topic describes how to modify the time zone of a Linux instance, as well as how to enable and configure the Linux NTP service to ensure accurate local time synchronization of the instance. In the example provided in this topic, Ubuntu 18.04 is used.​
What is NTP?​
Network Time Protocol (NTP) is an application-layer protocol in the TCP/IP protocol suite, designed for clock synchronization between clients and servers and providing highly accurate time calibration.​
Prerequisites​
  • If NTP is not installed, execute the following command to install it.​
  • ​
    sudo apt-get update​
    sudo apt-get install ntp​
    ​
  • The NTP service uses the User Datagram Protocol (UDP) to send and receive timestamps over port 123. Make sure that an inbound rule is added to the security group of the instance to allow inbound traffic on UDP port 123. For more information, see Creating security groups.​
Procedure​
Modify the time zone of a Linux instance​
  1. Connect to the Linux instance. For more information, refer to Logging in to Linux instances.​
You need to modify the time zone as the root account. Therefore, use the sudo command.​
  1. Execute the timedatectl list-timezones command to view the list of available time zones.​
You can also quickly view the list of available time zones in a continent. For example, you can execute the timedatectl list-timezones | egrep -o "Asia/*.*" command to quickly find available time zones in Asia.​
  1. Execute the following command to modify the time zone. In the example provided in this topic, the time zone is changed to Shanghai.​
  • ​
    timedatectl set-timezone "Asia/Shanghai"​
    ​
  1. Execute the following command to view the current time zone and check whether the modification is successful.​
  • ​
    timedatectl status | grep Time​
    ​
  • Sample output:​
  • ​​​
Start the standard NTP service​
  1. Connect to the Linux instance. For more information, refer to Logging in to Linux instances.​
  1. Execute the sudo systemctl restart ntp command to start the NTP service.​
  1. Execute the systemctl enable ntp command to specify that the NTP service automatically starts upon instance startup.​
  1. Execute the sudo systemctl status ntp command to view the running status of the NTP service.​
  • ​​​
  1. Execute the ntpq -p command to view the list of NTP service peers (optional).​
Configure custom NTP service​
  1. Connect to the Linux instance. For more information, refer to Logging in to Linux instances.​
  1. Execute the sudo vim /etc/ntp.conf command to open and edit the NTP service configuration file.​
  1. Enter i to start editing the file, and add # to the beginning of the NTP server lines that you currently do not need to comment them out.​
  1. Add the NTP server information in the following format: server <NTP_server_address> iburst. After you complete the editing, press the Esc key to exit the edit mode, enter :wq, and then press Enter to save the changes and exit the file.​
Volcano Engine provides NTP servers. For more information, see List of Volcano Engine NTP server addresses.​
  1. Execute the sudo systemctl restart ntp command to start the custom NTP service.​
  1. Execute the sudo systemctl status ntp command to view the running status of the NTP service.​
  1. (Optional) Execute the ntpq -p command to view the list of NTP service peers.​
Last updated: 2026.06.17 19:32:52