Change timezone in CentOS

from: https://www.vultr.com/docs/setup-timezone-and-ntp-on-centos-6

Input the following command in your terminal:

date

As you see, the Vultr CentOS 6 x64 OS uses the UTC time by default. You can modify it to any time zone as you wish, but using the local timezone of the server’s physical location is a best practice.

If our server was running in China, then we would use the “Asia/Shanghai” time zone:

rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/America/Torono /etc/localtime

You can navigate to the directory /usr/share/zoneinfo to find the appropriate time zone. There is an excellent resource on Wikipedia for timezone listings.

Input date again, you will find that the local system time has changed to CST (China Standard Time) GMT+0800.

Next, we will write the system time info into the hardware clock.

vi /etc/sysconfig/clock

Modify the content of this file as below.

ZONE="America/Toronto"
UTC=false
ARC=false

Save and quit.

:wq

Write the system time into the hardware clock.

hwclock --systohc --localtime

Input hwclock to see the result.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s