(Answer) (Category) Linux on PowerPC FAQ-O-Matic : (Category) System Configuration :
How to fix date/time/timezone from command line?
MINI-HOW-TO:  Fixing the date, time, and timezone

SEARCH KEYWORDS:  date, time, clock, timezone, CMOS, adjtime, localtime

BACKGROUND: Two date/time related problems are common on ppc linux distros: 1)
The first relates to dates being set somewhere in the early or mid-20th
century.  This is usually due to a dead hardware clock/PRAM battery.  If you
have this problem on a desktop Mac you might have your date show up as 23 Feb.
1955 (You know who's birthday) or if you have a portable it might be sometime
in 1903 or 1904.  If this happens- replace your battery and follow the steps
below to set the clock.  2) The second relates to the clock being off by a few
hours or possibly being totally screwed up.  There are multiple ways to address
these problems; a command-line method that uses standard *nix binaries is
described below.

There are two separate things keeping track of the date/time in a *nix system:
the hardware clock and the "kernel time".  The "date" command is used to access
the kernel time, and the "clock" command is used to access the internal
hardware clock (or CMOS).  Problems can arise when the two are not properly
synced.  Additionally, there are other files traditionally involved in setting
the local timezone, and even files that can be set to correct for internal
clocks that run a bit fast or slow (see references).  All steps below should be
typed on the command line as root.

STEPS:
(1)  See what day-date-time-timezone-year the kernel thinks it is.  Type:

        date

and you should see something like:

        Mon Aug 14 11:34:42 HST 2000

(2)  If your timezone is not correct, look under /usr/share/zoneinfo/ for a
location near you.  To set the timezone you need to make a symbolic link from
the appropriate file to /etc/localtime.  For me this looked like:

        ln -s /usr/share/zoneinfo/Pacific/Honolulu /etc/localtime

Some representatives from mainland US timezones include:

        /usr/share/zoneinfo/America/Los_Angeles
        /usr/share/zoneinfo/America/Denver
        /usr/share/zoneinfo/America/Chicago
        /usr/share/zoneinfo/America/New_York
        
If /etc/localtime already exists, do this:

        mv /etc/localtime /etc/localtimeOLD

and then create the symbolic link.       

(3)  If the date/time is not accurate, set it using the following options:

        date -s 'MM/DD/YYYY HH:MM:SS'

(4)  Now set the CMOS (hardware clock) to match the kernel time:

        clock -w  

(5)  If you don't want all this stuff to get messed up again when you reboot,
you need to link the kernel time to the hardware clock.  To do this enter:

        echo "clock -s" > /sbin/hwclock
        chmod +x /sbin/hwclock 

Now when /sbin/hwclock is run during the boot sequence it will set the kernel
time to match the CMOS time (which you just set).  This fixes an oversight/bug
in LinuxPPC that will hopefully be fixed in future ditributions.    

ALTERNATE:  If you dual-boot, you can just do steps 1, 2 and 5 above, and then
set your hardware clock using the MacOS date & time control panel.  This can be
used as a simple way to sync with a timeserver. 

RELEVANT LINKS
  Internal clock/PRAM battery:
  http://lists.linuxppc.org/listarcs/linuxppc-user/200006/msg01304.html

  Linking the hardware clock:
  http://lists.linuxppc.org/listarcs/linuxppc-user/200006/msg01317.html

  The clock mini-howto (includes instructions for setting /etc/adjtime):
  http://www.linuxdoc.org/HOWTO/mini/Clock.html

  The Linux Documentation Project: http://www.linuxdoc.org/

  Search Linux on PPC User's Mailing List:
  http://lists.linuxppc.org/lists/linuxppc-user

SOURCES/THANKS TO: Nelson Abramson, Jim, Ron Bean, and Rocky Shore (for
inspiring the how-to).
lemonds@hawaii.edu
[Append to This Answer]
Previous: (Answer) CD drive sound Help
Next: (Answer) Spanish console and X11 keyboard maps.
This document is: http://www.jonh.net/cgi-bin/lppcfom/fom?file=1042
[Search] [Appearance]
This is a Faq-O-Matic 2.717d.
Hosted by anduin.org and SourceForge Logo