Setting the timezone on CentOS
It’s a fairly simple operation. There are loads of timezone data files stored in:
/usr/share/zoneinfo
So for my CentOS install, to set my machine time on runtime to London time(GMT), I use:
Check current time zone:
date
That returns:
Wed Oct 1 07:43:58 CDT 2008
# # to fix it #
rm /etc/localtime
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime
Now check it’s ok
date
Returns:
Wed Oct 1 12:42:33 GMT 2008
Then to make sure the settings stay applied after a restart:
vim /etc/sysconfig/clock
change the zone line to:
ZONE="GMT"
In order to get the particular zone you wish to use you must associate ZONE with a file located in /usr/share/zoneinfo. It is wise to note the directory structure because if you need to set the timezone to that of Shanghai which is located in the Asia directory you will then have to set your ZONE variable to the following :
ZONE="Asia/Shanghai"
Or perhaps you need to set the timezone to that of East Brazil :
ZONE="Brazil/East"
Finally save the file /etc/sysconfig/clock and on next reboot the system will be set to the defined timezone.
Thanks.
Note vi worked for me, not VIM.