Wednesday, December 23, 2009

Linux: changing the time zone

I recently ran into a situation where a hosted client was in another timezone. I need the server we hosted to match there TZ. The steps are simple:

1. Backup the current TZ file.
mv /etc/localtime /etc/localtime.bak
2. Create a symbolic from the desired TZ to /etc/localtime.
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
3. Using rdate, update the current time.
rdate -s time-a.nist.gov
4.Set the ZONE information in /etc/sysconfig/clock
ZONE="America/los_Angeles"
5. Update the hardware clock
hwclock --systohc

Done!