Linux datetime

From Noah.org
Revision as of 16:13, 28 July 2008 by Root (talk | contribs)
Jump to navigationJump to search

Set timezone and clock on Linux

1. su to root

2. Find your timezone file under /usr/share/zoneinfo. For example:

   /usr/share/zoneinfo/US/Pacific

3. OPTIONAL: backup the current timezone configuration:

   cp /etc/localtime /etc/localtime.old

4. Create a symbolic link from the appropiate timezone to /etc/localtime.

   ln -sf /usr/share/zoneinfo/US/Pacific /etc/localtime

or

   ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

5. Use rdate or ntpdate to set the system time (ntpdate is better):

   /usr/sbin/ntpdate time.nist.gov

or

   /usr/bin/rdate time.nist.gov

6. Set the hardware clock to the system time:

   /sbin/hwclock --systohc

Correct for clock drift

For where its not possible to run ntpd you may use adjtimex to correct for systematic drift.

aptitude install adjtimex