Andrei Ivanov wrote:

> > ok, that is a little too basic
> >
> > i run
> >
> > date Wed --nothing happens it says invalid date
> >
> > lets be practical
> > if i want to change the time to
> > Wed Mar 8 6:16:00 PST 2000    --what do i do?
>
> date MMDDhhmmYY
> so
> date 0308061600
>      MMDDhhmmYY
> MM month
> DD day
> hh hour
> mm minute
> YY year
> Andrew
> -------------------------------------------------------------------------
>  Andrei S. Ivanov

It can actually be a bit more complex than that....

You have two (2) clocks: the hardware (CMOS) clock, and the system (software) 
clock.
The hardware clock remembers the time even when the computer is turned off. 
When the
computer is turned on, Linux first reads the hardware clock and then sets the
software clock accordingly.

If you have a Linux-only system, you probably want to set the hardware clock to 
UTC
time. If you have a dual-boot system (Windows and Linux), you probably want to 
set
the hardware clock to local time.

The command Andrei gave above sets the system clock according to your (the
sysadmin's) preference rather than letting the system get the time from the 
hardware
clock. Next time you restart the system, the system will again read the hardware
clock and set the system clock according to it. This does not necessarily mean 
the
two clocks are set to the same time, because there's a third component in the 
mix
also: the time zone setting. When Linux boots up, it reads the hardware clock, 
and it
reads the time zone setting in your Linux system, calculates the local time 
according
to those two things, and then sets the system clock with the result.

So Andrei's suggestion will set the clock for you, but it may not take care of 
future
boots. You also need to set the hardware clock, either via your computer's CMOS 
setup
program - usually DEL or F1 or Ctrl-Alt-ESC during the PowerOnSelfTest (POST) 
or via
the hwclock command.

Once your hardware clock is set correctly, then you need to make sure the time 
zone
setting is correct (with tzconfig) so that on bootup Linux can set the system 
clock
to the correct local time.

So you have three steps:
 1) Set the CMOS (hardware) clock (by rebooting and entering the CMOS setup or 
by
using hwclock)
    1a) set the system clock with Andrei's suggestion above
    1b) set the hardware clock with "hwclock --systohc" which copies the system 
time
to the hardware clock
 2) Tell Linux which timezone you're in (with tzconfig).
 3) Tell Linux whether the hardware clock is set to local time or UTC (set 
"UTC=yes"
or "UTC=no" in /etc/defaults/rcS).

Next time you reboot the startup files will read the hardware clock and then 
set the
software clock, adjusting for timezones accordingly.

Reply via email to