Quantcast
Viewing all articles
Browse latest Browse all 26

Setting Linux CentOS 7.2 Date Timezone

A correct date time in a newly installed server is important, but it’s overlooked sometimes until it cause some strange problems in synchronization of data between servers.

Here’s a simple guide to remember in setting Linux CentOS 7.2 date timezone.

Check the current date/timezone:
# date
Thu Aug 25 02:42:13 UTC 2016

Check available timezone:
# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul

Pacific/Pohnpei
Pacific/Port_Moresby
Pacific/Rarotonga
Pacific/Saipan
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Wake
Pacific/Wallis
UTC
#

Check available timezone from Asia:
# timedatectl list-timezones | grep Asia
Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
Asia/Aqtau
Asia/Aqtobe
Asia/Ashgabat
Asia/Baghdad
Asia/Bahrain
Asia/Baku
Asia/Bangkok

Asia/Tokyo
Asia/Tomsk
Asia/Ulaanbaatar
Asia/Urumqi
Asia/Ust-Nera
Asia/Vientiane
Asia/Vladivostok
Asia/Yakutsk
Asia/Yekaterinburg
Asia/Yerevan
#

Set timezone to Asia/Bangkok:
# timedatectl set-timezone Asia/Bangkok

Check again the current date/timezone:
# date
Thu Aug 25 11:03:19 ICT 2016
#

The command timedatectl basically created a symlink between /etc/localtime to the desired timezone file in the system located in /usr/share/zoneinfo/ directory.

The link can be verified:
# ls -l /etc/localtime
lrwxrwxrwx 1 root root 34 Aug 25 11:03 /etc/localtime -> ../usr/share/zoneinfo/Asia/Bangkok
#

Thus, another way to set the date timezone by removing the existing localtime file:
#rm /etc/localtime

Create a new localtime file symbolic link to the timezone:
#ln -s /usr/share/zoneinfo/Asia/Bangkok /etc/localtime

Verify again the link:
# ls -l /etc/localtime
/etc/localtime -> ../usr/share/zoneinfo/Asia/Bangkok

That concludes the steps in setting up Linux CentOS 7.2 Date Timezone and it might apply to other version of CentOS.


Viewing all articles
Browse latest Browse all 26

Trending Articles