2

I have an issue with Ubuntu Quantal, as it shows the wrong time. It is completely messy, the right time from time.is now is 09.43 and my clock shows 17.48. I am using ntp service and I already checked the timezone and it is correct. I also checked the hardware clock through
sudo hwclock --show
sudo dpkg-reconfigure tzdata and this is right too. I also tried
sudo dpkg-reconfigure tzdata
but with bad luck. What else can I try?

As asked, here my /etc/ntp.conf

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org
server time.nist.gov

# Use Ubuntu's ntp server as a fallback.
server ntp.ubuntu.com

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient


In addition, the ntp service was not running when I turned on my laptop today.

2
  • 1
    Actually, I already solved the problem. I posted this question because I didn't find a proper solutions in my research. So, here what I had to do: simply set up the clock manually issuing the command <br />sudo date --set="2012-12-13 09:41:40AM"<br /> and then configuring the clock to use the ntp service. Now, when I check time.is, it clearly shows that my time is exact, as it says *The difference from Time.is was +0.076 seconds (±0.013 seconds)*<br /> I am answering my own question as I know this is encourage by the stackexchange network and it can be useful for other people.
    – mardavi
    Dec 13, 2012 at 8:54
  • 1
    I had to use comment due to my bad reputation, but I will soon post the same as the answer!
    – mardavi
    Dec 13, 2012 at 8:55

1 Answer 1

3

NTP will not adjust a clock that is far out of sync (greater than 1000 seconds by default) with what it understands the time to be.

This can be overridden by issuing:

sudo ntpd -g 

However ideally, you have this execute when the ntp daemon is first started. To do this, add (or modify) the following line to /etc/default/ntp

NTPD_OPTS='-g'

This will make sure the time is correctly synced at boot time no matter how far it is out and then ntp will keep it accurate ongoing.

Usually, ntp is started at boot time, but if you find from ps auwx | grep ntp that it is not, then you can add it as a startup daemon:

sudo update-rc.d ntp defaults
6
  • Out of curiosity, I tried resetting the time to a very wrong value and then applying your solutions. It didn't work, plus I checked out the file /etc/default/ntp and it already shows the -g option. Then, I really don't understand why I first have to set the correct time maanually and then I can switch to ntp. BTW, I hope ubuntu will keep my setting when I will reboot
    – mardavi
    Dec 13, 2012 at 10:40
  • @mardavi Interesting, so the real question here is why this isn't working, and yet ntp in general is. Where did you see this message: The difference from Time.is was +0.076 seconds (±0.013 seconds)
    – Paul
    Dec 13, 2012 at 10:58
  • sorry for the delay, anyway from this website - time.is
    – mardavi
    Dec 13, 2012 at 13:28
  • @mardavi My guess is that you don't actually have ntp working, and that is why the time is not correctly set at boot. Could you edit your question and add the contents of /etc/ntp.conf and do a ps auwx | grep ntp to confirm it is running?
    – Paul
    Dec 14, 2012 at 0:59
  • I should check better, but today when I turned on my laptop the laptop I saw the ntp service was not running. I will now edit my question with your requests.
    – mardavi
    Dec 14, 2012 at 10:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .