We have come across several times where it would be nice to change the timezone on the servers we are administering. While you would think this would be straight forward, it's not as easy as you'd think. Usually, with a GUI you just set the timezone, and you're done. On a server, there's no GUI to check the timezone.
So how exactly do you change the timezone? This line of code changes your system timezone to "New York" or commonly known as "Eastern" time.
cp /usr/share/zoneinfo/America/New_York /etc/localtime
If you were thinking you want to use UTC, you'd do the following:
cp /usr/share/zoneinfo/UTC /etc/localtime
If you are looking for a different timezone, you can find them all:
ls /usr/share/zoneinfo | less
When you find the correct timezone, copy it over the localtime file. We also highly recommend keeping your time updated using NTP. To do so, run this:
yum install -y ntp ntpdate && chkconfig ntpdate on && service ntpdate start
This downloads the NTP service which will synchronize with time servers on the internet, sets the service to turn on at boot time, and starts the service.