search on lynty.com

Related Articles

date (time zone configurations)

Print PDF
  1. Logged in as root, check which timezone your machine is currently using by executing `date`.
  2. You'll see something like Mon 17 Jan 2005 12:15:08 PM PST, PST in this case is the current timezone.
  3. Change to the directory /usr/share/zoneinfo
  4. here you will find a list of time zone regions. Choose the most appropriate region, if you live in Canada or the US this directory is the "America" directory.
  5. If you wish, backup the previous timezone configuration by copying it to a different location. Such as

 

mv /etc/localtime  /etc/localtime-old
  1. Create a symbolic link from the appropiate timezone to /etc/localtime. Example:
    ln -sf /usr/share/zoneinfo/Europe/Amsterdam  /etc/localtime
  2. If you have the utility rdate, update the current system time by executing
    /usr/bin/rdate -s time-a.nist.gov
    
  3. Set the ZONE entry in the file /etc/sysconfig/clock file (e.g. "America/Los_Angeles")
  4. Set the hardware clock by executing:
    /sbin/hwclock --systohc
    

 

 

 Tips

  • The time server parameter for rdate can be any public server that supports the RFC-868 time protocol. A list of public RFC-868 servers can be found at [2]. Note: As of April 2007, NIST announced it would phase out support for RFC-868 (scroll to the bottom of [3] to see the announcement). This has not happened as of April 2009).
  • On some versions of RedHat Linux, Slackware, Gentoo, SuSE, Debian, Ubuntu, and anything else that is "normal", the command to display and change the time is 'date', not 'clock'
  • On RedHat Linux there is a utility called "Setup" that allows one to select the timezone from a list, but you must have installed the 'redhat-config-date' package. < note... on RHEL5 it is actually 'system-config-date' >
  • On mobile phones and other small devices that run Linux, the time zone is stored differently. It is written in /etc/TZ, in the format that is described, for instance, in [4]. Edit this file manually or use echo (for instance, echo GMT0BST > /etc/TZ to set the the timezone of the United Kingdom).
  • To setup UTC :
  • vi /etc/sysconfig/clock and change the UTC line to: "UTC=true"
  • On systems that use dpkg (for example Debian and Ubuntu/Kubuntu), you should try "sudo dpkg-reconfigure tzdata". This will set up everything correctly in very few, simple steps.

source:
http://www.wikihow.com/Change-the-Timezone-in-Linux







###Time Zone Configuration###


Background - The Earth is divided into time zones that are 15 degrees of longitude each, for this corresponds to the amount of angular distance the Sun appears to travel in 1 hour. 0 degrees longitude runs through the Royal Observatory in Greenwich, England. This is the origin of Greenwich Mean Time, or GMT. For all practical purposes, GMT and UTC are the same. To complicate matters, some countries observe Daylight Savings Time (DST), while others do not. Even within some countries, some states or districts do not observe DST while the rest of the country does! DST can also begin and end on different days in different countries! What a mess...

There are several files and directories that are used for time zones, and several tools:

/etc/sysconfig/clock - this is a short text file that defines the timezone, whether or not the hardware clock is using UTC, and an ARC option that is only relevant to DEC systems.


/etc/localtime - this is a symbolic link to the appropriate time zone file in /usr/share/zoneinfo

/usr/share/zoneinfo
- this directory contains the time zone files that were compiled by zic. These are binary files and cannot be viewed with a text viewer. The files contain information such as rules about DST. They allow the kernel to convert UTC UNIX time into appropriate local dates and times.

/etc/rc.d/rc.sysinit
- This script runs once, at boot time. A section of this script sets the system time from the hardware clock and applies the local time zone information.

/etc/init.d/halt - This script runs during system shutdown. A section of this script synchronizes the hardware clock from the system clock.

/etc/adjtime - This file is used by the adjtimex function, which can smoothly adjust system time while the system runs. settimeofday is a related function.


redhat-config-date or dateconfig - These commands start the Red Hat date/time/time zone configuration GUI. Both commands failed to change the timezone in two different stock Red Hat 8.0 systems. They also failed to create a working ntp.conf file for the NTP server. The timezone problem went away after upgrading from the installed RPM, redhat-config-date-1.5.2-10, to a newer RPM from a Red Hat beta release, redhat-config-date-1.5.9-6.

zic - (The time zone compiler) Zic creates the time conversion information files.


zdump - This utility prints the current time and date in the specified time zone. Example:


# zdump Japan
Japan Sat Mar 29 00:47:57 2003 JST
# zdump Iceland
Iceland Fri Mar 28 15:48:02 2003 GMT


In order to manually change the timezone, you can edit the /etc/sysconfig/clock file and then make a new soft link to /etc/localtime. Here is an example of changing the timezone manually to "America/Denver":

1. Select the appropriate time zone from the /usr/share/zoneinfo directory. Time zone names are relative to that directory. In this case, we will select "America/Denver"

2. Edit the /etc/sysconfig/clock
text file so that it looks like this:

ZONE="America/Denver"
UTC=true
ARC=false

Of course, this assumes that your hardware clock is running UTC time...


3. Delete the following file: /etc/localtime

4. Create a new soft link for /etc/localtime. Here is an example of step 3 and step 4:


# cd /etc
# ls -al localtime
lrwxrwxrwx 1 root root 39 Mar 28 07:00 localtime -> /usr/share/zoneinfo/America/Los_Angeles

# rm /etc/localtime

# ln -s /usr/share/zoneinfo/America/Denver /etc/localtime
# ls -al localtime
lrwxrwxrwx 1 root root 34 Mar 28 08:59 localtime -> /usr/share/zoneinfo/America/Denver

# date
Fri Mar 28 09:00:04 MST 2003
 

 source:
http://www.vanemery.com/Linux/RH-Linux-Time.html

 

Related Articles+