How to change time zone from command line on RHEL.

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 10

Issue

  • How to change time zone from command line on RHEL 7/8/9/10

Resolution

There is a different way for us to change time zone since RHEL7.

  1. Find the desired time zone with the below command or we can use the command "tzselect" to find the desired time zone..Let's make "Asia/Shanghai" as an example.

     # timedatectl list-timezones
    
  2. Change the time zone.

     # timedatectl set-timezone Asia/Shanghai
    
  3. Verify the status of time zone.

     # timedatectl status
    

Important Note

Some applications and services such as rsyslogd and crond make use of local time zone data to convert time from epoch UTC to local system time. The time zone data is loaded and cached based on the time zone set for the system when the process started. When changing the time zone of a system, it is recommended that the system be rebooted to ensure that all processes are restarted and make use of the new time zone conversions.

Root Cause

timedatectl is a new feature on RHEL7. It may be used to query and change the system clock and its settings. See more at man timedatectl or Changing the Time Zone

SBR
Components
Category
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.