How can I get ntpdate functionality from ntpd ? > when the clock is manually set to incorrect time (say 10 > minutes forward) and ntpdate is run, the correct time is immediately set. > But running ntpd -qg does not correct the time at all. Ntpd is not running > as a daemon, I only intend to run it once to set the correct time. > My /etc/ntp.conf reads this: > > server 0.hu.pool.ntp.org iburst > server 1.hu.pool.ntp.org iburst > server 2.hu.pool.ntp.org iburst > server 3.hu.pool.ntp.org iburst > server hu.pool.ntp.org iburst > driftfile /var/db/ntp.drift > restrict default ignore > > So what is wrong? > Why don't I get an updated/corrected time with ntpd -qg? Solution: Remove or comment-out the "restrict" line from ntp.conf and the sync will work! For some reason, the "restrict default ignore" line screws-up the ntpd client part and makes it unable to fetch the current time from the remote timeserver. This is a shame, as our own handbook gave me the instructions to set this up the way I did. Well, the handbook is flawed here! Instead of setting ntpd into a "client only" mode which most people expect, the "restrict default ignore" line actually cripples the "client" mode operation, making one's ntpd unable to sync local time to the time of a remote timeserver. Summary: 1., Make sure you only have "server" and "driftfile" directives in your ntp.conf and NO restrict lines (at least for the first few tests, then you can start playing with restrict if you want to)! #Sample ntp.conf file for "immediate" sync server 0.hu.pool.ntp.org iburst server 1.hu.pool.ntp.org iburst server 2.hu.pool.ntp.org iburst server 3.hu.pool.ntp.org iburst server hu.pool.ntp.org iburst driftfile /var/db/ntp.drift #And no restrict lines please!!! 2A., If you don't need ntpd running as a daemon and slowly fiddling with your computer's timekeeping but you want to set your local time to the current proper time once now, you run: ntpd -qg Now your time is synced and you are done. Of course, you can run the same command again if you want/need to, or you can schedule to run it at certain times from crontab. 2B., You may want to keep ntpd running and continuously fiddling with your computer's clock by slightly adjusting its ticking speed. The advantage of this is that after a few days of running ntpd learns how inaccurate your built in clock is and how to compensate for that. Once that has been established, ntpd will be able to keep your ticking accurate, therefore your computer will keep accurate time without the need of syncing it to a time-server. So your computer time will stay accurate even if it has no internet connection for weeks or months (assuming that the computer runs 24/7). For this you need the line below in your /etc/rc.conf: #Sample rc.conf settings for continuously running ntpd ntpd_enable="YES" #This will keep ntpd running continuously 2C., Probably the best way to go is to combine the above two methods, so that each time your computer is rebooted your clock is immediately adjusted to the time-server's accurate time, and from then on it will be controlled by ntpd to keep ticking accurately. For that you need to add the lines below to your /etc/rc.conf: #Sample rc.conf settings for boot-time timesync and also keep running ntpd ntpd_enable="YES" #This will keep ntpd running continuously ntpd_sync_on_start="YES" #This will immediately sync time once upon each reboot Comments: Consider 2A as having a cheap and inaccurate children's watch which you sync to your 12 o'clock radio news every day so that you can trust the time it shows for the rest of the day until next noon. Consider 2B as having the same cheap and inaccurate children's watch for which you get a little upgrade component that turns it into a high precision Swiss wrist watch. (now try to say this out loud: Which wrist watch is a Swiss wrist watch? :-) Either way, you make your watch to show accurate time. The two methods are quite different but the effective result is about the same. Pick the one that suits you better.