I recently needed to set up a CentOS 5 box and completely forgot how to set the timezone. There’s apparantly a nice easy text GUI for doing it in RHEL but I couldn’t find the same thing on the CentOS box so here’s how to do it. It should also work for most Linux systems.
Set the timezone on CentOS
The timezone files are located at /usr/share/zoneinfo and you simply need to create a symbolic link from /etc/localtime to point to the correct timezone file, located under that directory.
For example, I needed to set it to Auckland’s time, which is done as follows:
ln -sf /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
Good oh, that now saves me from having to Google how to do it next time 😉
No, I probably won’t remember without having to look it up here again…
I’ve had some issues on a particular bunch of CentOS 5 virtual machines (I think they were all based on the same template) where doing the above didn’t work. I’ve written "fix the timezone data on CentOS" as a follow up post to show a possible solution.