Changing the timezone on RHEL and CentOS

Seems like an easy enough thing to do but 99% of the websites out there that walk you through changing the timezone on a CentOS or RHEL server fail to mention one critical step; the changing of /etc/sysconfig/clock.  If that file is not updated, future rpm updates, reconfigs, etc. will eventually cause your timezone to reset and that will possibly cause you big problems.

So, the correct steps to change the timezone are:

  1. rm -f /etc/localtime
  2. ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
  3. Edit /etc/sysconfig/clock and put the appropriate timezone in the file or the server will revert to the wrong one next time the tzdata updates.

Obviously the second step should be altered to match whatever timezone you actually want to use; you can find them all under /usr/share/zoneinfo/ in both city format and GMT +/- offsets.

Leave a Reply

Your email address will not be published. Required fields are marked *