How to set or change time zone on CentOS 8

engrmahabub
Mahabubur Rahman
Published on Nov, 07 2023 2 min read 0 comments
image

A time zone is an area which observes a uniform standard time for legal, commercial and social purposes. Time zones tend to follow the boundaries between countries and their subdivisions instead of strictly following longitude, because it is convenient for areas in frequent communication to keep the same time.

 

Using of correct time zone is necessary for lots to system related process and tasks. For example, scheduled job or cronjobs executing. If the time zone not set correctly the job will execute incorrect time. Or if you send a file or message from one continent to another continent, the time zone is very important. 

 

Every OS, the system time zone is set during the installation process, but it can be change any time.

 

So in this article we will discuss on how to set or change the time zone on CentOS 8.

 

Check the current Time Zone

In CentOS 8 you can see the current time zone by using timedetectl terminal commend. This commend also show you the current time and date of your system. This commend is available on all linux based OS.

[devops@bgd1-b-02 ~]$ timedatectl
Output
               Local time: Sat 2023-11-04 16:06:41 UTC
           Universal time: Sat 2023-11-04 16:06:41 UTC
                 RTC time: Sat 2023-11-04 16:06:42
                Time zone: UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Above the output show the system time zone. In this example the current time zone is set to UTC.

List available Time Zone in CentOS

Before change the time zone you need to find out all available timezone in CentOS. Timezone are using “Region/City” format. To list available time zone use timedatectl list-timezones commend - 

[devops@bgd1-b-02 ~]$ timedatectl list-timezones
Output

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
...

Above the output show the available time zone.

Changing Time Zone in CentOS

Once you identify which time zone you need to set, run the following commend to set it - 

[devops@bgd1-b-02 ~]$ set timedatectl set-timezone your_timezone

For example you change the system timezone to Asia/Dhaka

[devops@bgd1-b-02 ~]$ set timedatectl set-timezone Asia/Dhaka

 

Run the timedatectl command to verify the changes:

 

[devops@bgd1-b-02 ~]$ timedatectl
Output
               Local time: Sat 2023-11-04 22:23:14 +06
           Universal time: Sat 2023-11-04 16:23:14 UTC
                 RTC time: Sat 2023-11-04 16:23:15
                Time zone: Asia/Dhaka (+06, +0600)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

 

 

0 Comments