Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

on linux to sync time with ntp you say

ntpdate pool.ntp.org

however after reboots, the time gets reset to some odd value again. is there a way to persist the changes?

how do I set the computer clock to the correct time and then keep it correct after reboot?

share|improve this question

3 Answers 3

As you discovered, ntpdate is a one-shot deal.

You want ntpd.

share|improve this answer
    
ntpd alone will not help maintaining the time across reboots (it will only correct the time some seconds(?) after a reboot, and will not work if there's no net connection). –  sleske Feb 1 '12 at 8:05
    
However, ntpd can be forced to sync time during initial start, just like ntpdate does: just use ntpd -g. It makes ntpd to forcibly sync to clock, no matter the time difference. This happens only once, after the initial sync ntpd will run as usual. And ntpdate does no good either if there's no network connection. –  Janne Pikkarainen Feb 1 '12 at 8:16
    
@JannePikkarainen: True, ntpdate does no good if there's no network connection, but hwclock does. You need to use hwclock if you want the correct time right after booting. –  sleske Feb 1 '12 at 10:08
  1. Firstly make sure your system has time/date correct. (ntp/timezone)
  2. Then, run hwclock --systohc (Theoretically this should not be necessary, as most Linux systems do this automatically on shutdown, but it can't hurt.)

This should reset your computer's real-time clock (RTC, a.k.a "hardware clock" or "BIOS clock") to the system time, and should make your sync persistent across reboot.

Modern Linux systems automatically set the system time from the RTC during bootup, thus setting the RTC makes sure the system time is correct right after booting. Using ntpd or similar to synchronize with a time server is a good addition, to keep the clock accurate in the longer run.

share|improve this answer
    
I took the liberty of expanding your already good answer a bit. Hope you don't mind. –  sleske Feb 1 '12 at 8:10
    
@sleske no probs !! whatever it takes to be more readable and better –  kaji Feb 1 '12 at 8:32

If any other solution works, check the following as last resource.

How old is the computer that is showing the Issue?

If it's an old computer, you should check if the motherboard battery is still with charge (yes, there is a little clock battery that allows the computer to hold some data as time/date across reboots).

If it's discharged, a simple battery replacement will fix it for good.

share|improve this answer
    
Good point. Note that problems with the clock battery will only affect the RTC / hardware clock. The system clock used by the OS is maintained independently. –  sleske Feb 1 '12 at 10:09

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.