Help Center/ Elastic Cloud Server/ Troubleshooting/ Linux ECS Issues/ How Do I Change the Time Zone on ECSs Running CentOS or EulerOS?
Updated on 2023-03-30 GMT+08:00

How Do I Change the Time Zone on ECSs Running CentOS or EulerOS?

Scenarios

This section describes how to change the time zone in ECSs running CentOS or EulerOS.

Constraints

  • The operations described in this section have been verified to work on ECSs running CentOS 6.8 or CentOS 7.5.
  • Asia/Shanghai (UTC+08:00) is used as an example.

CentOS 6 or RHEL 6

  1. Run the following command to permanently change the time zone to Asia/Shanghai (UTC+08:00):

    # cp -vf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

  2. Log in to the ECS and run the following command to check whether the change has taken effect:

    # date |awk '{print $5}'

CentOS 7 or EulerOS

  1. Run the following command to view all available time zones:

    # timedatectl list-timezones

  1. Run the following command to change the time zone to Asia/Shanghai (UTC+08:00):

    # timedatectl set-timezone Asia/Shanghai

  2. Run the following command to check the current time and date:

    # timedatectl status