Description

This article provides information on how to change the time zone settings on the PE/LC/Linux

Symptoms

  • How do I change the time zone settings on the PE/LC?
  • The date and hwclock don't match.
  • How do I sync the sysclock to the hwclock?

Solution

To change the time zone in PE/LC use the sudo timedatectl set-timezone command followed by the long name of the time zone you want to set

Step 1: To view the current time zone, run timedatectl

timedatectl

Note: The system time zone is configured by symlinking the /etc/localtime file to a binary time zone’s identifier in the /usr/share/zoneinfo directory.

Another way to check the time zone is to view the path the symlink points to using the ls command:

ls -l /etc/localtime

 

Step 2: Changing the Time Zone in Linux

Before changing the time zone, you’ll need to find out the long name of the time zone you want to use. The time zone naming convention usually uses a “Region/City” format.

To view all available time zones, use the timedatectl command or list the files in the /usr/share/zoneinfo directory:

timedatectl list-timezones

Once you identify which time zone is accurate to your location, run the following command as root or sudo user:

sudo timedatectl set-timezone <your_time_zone>

For example, to change the system’s timezone to America/New_York you would type:

sudo timedatectl set-timezone America/New_York

To verify the change, invoke the timedatectl command again:

timedatectl

 

Step 3: Or changing the Time Zone by Creating a Symlink

If you are running an older linux distribution and the timedatectl utility is not present on your system, you can change the timezone by symlinking /etc/localtime to the time zone in the /usr/share/zoneinfo directory.

Remove the current symlink or file:

sudo rm -rf /etc/localtime

Identify the timezone you want to configure and create a symlink :

sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

Verify it either by listing the /etc/localtime file or invoking the date command:

# date
  • Check the hwclock
    [root@space-005056980055 etc]# hwclock
    Wed 07 Dec 2011 06:13:59 PM UTC -0.828736 seconds
  • Sync sysclock to hwclock:
    [root@space-005056980055 etc]# hwclock –-systohc

    [root@space-005056980055 etc]# date
    Wed Dec 7 01:15:55 UTC 2011

    [root@space-005056980055 etc]# hwclock
    Wed 07 Dec 2011 01:15:59 AM UTC -0.188099 seconds

Note : If you face any issues, please contact JUNIPER JTAC Support for assistance.

Modification History

2024-02-05: Article published