How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

March 31, 2008

How to Change the Timezone in Linux

Filed under: Linux — admin @ 2:30 pm

1. Logged in as root, check which timezone your machine is currently using by executing `clock`. You’ll see something like “Mon 17 Jan 2005 12:15:08 PM PST -0.461203 seconds”, PST in this case is the current timezone.

2. Change to the directory to /usr/share/zoneinfo, here you will find a list of time zone regions. Change to the most appropriate region, if you live in Canada or the US this directory is the “Americas” directory.

3. If you wish, backup the previous timezone configuration by copying it to a different location. Such as `cp /etc/localtime /etc/localtime-old`.

4. Copy over the most appropriate timezone to /etc/localtime. Example: `cp EET /etc/localtime`.

5. If you have the utility rdate, update the current system time by executing `/usr/bin/rdate -s time.nist.gov`.

6. Set the hardware clock by executing: ` /sbin/hwclock –systohc`

HINT:

On some versions of RedHat Linux the command to display and change the time is ‘date’, not ‘clock’

* Some applications (such as PHP) have separate timezone settings from the system timezone.

* On some systems, /etc/localtime is actually a symlink to the appropriate file under the /usr/share/zoneinfo directory (rather than a copy of that file).

* On some systems, there is a system utility provided that will prompt for the correct timezone and make the proper changes to the system configuration. For example, Debian provides the “tzsetup” utility.

Also on some server you may use  export TZ=Europe/Buchares for exampl . To check this variable you may use echo $TZ. If you use this, I think the /etc/localtime is not consider . So if you use export you should not use ln -sf , because is useless until a reboot.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress