Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If I change my system time on Debian which files would be modified?

Would it be /etc/default/rcS?

Also, is default time on Debian Dec 31 1969?

share|improve this question
add comment

1 Answer

Current time information is not stored in a file, rather it's synced from your hardware clock with /sbin/hwclock during boot. Seeing this date, usually means, your system clock has been reset, this is often caused by a faulty battery on your system board (a CMOS battery),

The date Dec 31 1969 is the epoch date (representing this number in bits this would be all zeros), when your system resets the system clock, it is reset to the epoch date (all zeros).

How to fix the issue

  1. Set your current time with date (directions are in man date)
  2. Sync your hwclock to the system time, hwclock --systohc

And you're back in business. For continual syncing of the clock with an external source you should look at ntp.

If you would like to test your CMOS battery, the simplest way to do so is to shutdown your system, remove the power cord, wait for about 5 minutes (to remove stand-by power, and let the capacitors drain), then start everything back up. If your clock has reset again, get a new battery. You can usually find the correct battery at a drugstore. If this is a server, you should contact your vendor for a replacement (ASAP).

I'm not aware of any mechanism within Linux that would allow you to monitor the state of your CMOS battery.

share|improve this answer
1  
Don't most BIOSes reset to 1/1/1980 or 1/1/2000 or something? –  Mikel May 12 '12 at 22:51
    
Seconded. Last time I made use of CMOS reset, the default was 2002/1/1. This date is the default for about every post-2002 BIOS since there aren't that many date bits in the CMOS. –  moshbear May 13 '12 at 1:33
    
@moshbear if Unix time is a 32 bit number how many bits are in the CMOS? And how does it "upscale" from a lower value? –  Joseph Kern May 13 '12 at 2:49
    
It probably returns the CMOS value incremented by some constant in the BIOS. –  moshbear May 13 '12 at 3:00
1  
You should also note that ntp will refuse to change the time if the difference between the server's time and the local host's time is too great (it's a security feature). I'm not sure how/if you can change this, but ntpdate doesn't care and it's a good tool to have in this case (bring down your ntpd temporarily before using it). –  Alexios May 13 '12 at 10:26
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.