kahlenberg
Posts: 41
Joined: Mon Jul 29, 2013 10:47 am

[SOLVED] time and date are incorrect

Sun Nov 03, 2013 6:57 am

Hi community,

I am dealing with a time&date problem, I have wheezby installed and since a couple of weeks date is 4 days wrong and time is also wrong. Timezone is correct, Europe/Vienna. I have changed ntp.conf and restarted ntp but nothing happend. How can I solve the poblem?
Here is my ntp.conf

Code: Select all

# /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


# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>

server 0.debian.pool.ntp.org iburst
server 1.debian.pool.ntp.org iburst
server 2.debian.pool.ntp.org iburst
server 3.debian.pool.ntp.org iburst


# 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


Last edited by kahlenberg on Tue Nov 05, 2013 12:07 pm, edited 1 time in total.

User avatar
rpdom
Posts: 16121
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: time and date are incorrect

Sun Nov 03, 2013 7:20 am

It sounds like your ntpd isn't getting the time from a server, even though your ntp.conf file looks ok.

You can start debugging the problem by looking at the output of "ntpq -s". That will list all servers that ntp is trying to use and stats about the connections.

kahlenberg
Posts: 41
Joined: Mon Jul 29, 2013 10:47 am

Re: time and date are incorrect

Sun Nov 03, 2013 9:07 am

Thank you for quick reply. I tried the command ntpd -s, but it says ntpd: option 'statsdir' requires an argument. I also tried other option -p, it says ntpd: option 'pidfile' requires an argument, although they are already set in the config file, I think.
I have no idea.

User avatar
rpdom
Posts: 16121
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: time and date are incorrect

Sun Nov 03, 2013 9:49 am

I mentioned the ntpq command, not ntpd. ntpq can be used to query the ntp setup.

I was wrong about the option though. The correct format is "ntpq -p", which should give something like:

Code: Select all

[email protected]:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp.itarium.ch  193.79.237.14    2 u   39 1024  377   37.420   -3.901   3.342
+n106.navy.fastw 192.53.103.108   2 u  736 1024  377   21.793    1.033   2.976
-freya.syari.net 192.93.2.20      2 u  164 1024  377   18.311    4.209   2.152
*www.danzuck.ch  192.53.103.104   2 u  920 1024  377   27.499   -1.733   3.145
[email protected]:~$ 
The names and values will probably be different for you.

User avatar
DougieLawson
Posts: 37111
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: time and date are incorrect

Sun Nov 03, 2013 10:18 am

kahlenberg wrote:Hi community,

I am dealing with a time&date problem, I have wheezby installed and since a couple of weeks date is 4 days wrong and time is also wrong. Timezone is correct, Europe/Vienna. I have changed ntp.conf and restarted ntp but nothing happend. How can I solve the poblem?
Start by shutting down ntpd with: /etc/init.d/ntp stop
Then use raspi-config to get the timezone set correctly (Option 4 change internationalization options from the main menu, then Option I2 set timezone from the submenu).
When ntpd starts it should do an initial sync with the time server to set the clock, but if your clock is off by too many days it won't work. So reset the clock with: date -s "3 Nov 2013 10:18:00"
Then restart ntp with: /etc/init.d/ntp start
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

kahlenberg
Posts: 41
Joined: Mon Jul 29, 2013 10:47 am

Re: time and date are incorrect

Sun Nov 03, 2013 10:45 am

Oh, sorry I misread the comment. I run "ntpq -p", here is output:

Code: Select all

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 172.16.20.40    .INIT.          16 u    - 1024    0    0.000    0.000   0.000
It seems that it is not getting time from ntp server. I don't know why.
rpdom wrote:I mentioned the ntpq command, not ntpd. ntpq can be used to query the ntp setup.

I was wrong about the option though. The correct format is "ntpq -p", which should give something like:

Code: Select all

[email protected]:~$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+ntp.itarium.ch  193.79.237.14    2 u   39 1024  377   37.420   -3.901   3.342
+n106.navy.fastw 192.53.103.108   2 u  736 1024  377   21.793    1.033   2.976
-freya.syari.net 192.93.2.20      2 u  164 1024  377   18.311    4.209   2.152
*www.danzuck.ch  192.53.103.104   2 u  920 1024  377   27.499   -1.733   3.145
[email protected]:~$ 
The names and values will probably be different for you.

kahlenberg
Posts: 41
Joined: Mon Jul 29, 2013 10:47 am

Re: time and date are incorrect

Sun Nov 03, 2013 10:52 am

Thank you, I tried it now and it seems to be OK. We will see after next sync.
DougieLawson wrote:
kahlenberg wrote:Hi community,

I am dealing with a time&date problem, I have wheezby installed and since a couple of weeks date is 4 days wrong and time is also wrong. Timezone is correct, Europe/Vienna. I have changed ntp.conf and restarted ntp but nothing happend. How can I solve the poblem?
Start by shutting down ntpd with: /etc/init.d/ntp stop
Then use raspi-config to get the timezone set correctly (Option 4 change internationalization options from the main menu, then Option I2 set timezone from the submenu).
When ntpd starts it should do an initial sync with the time server to set the clock, but if your clock is off by too many days it won't work. So reset the clock with: date -s "3 Nov 2013 10:18:00"
Then restart ntp with: /etc/init.d/ntp start

Carsten
Posts: 1
Joined: Sun Nov 03, 2013 9:35 pm

Error mounting settings partition

Sun Nov 03, 2013 9:40 pm

Okay so this has nothing to do with this but I'm totally new to this but anyway I got the Pi to work but now on boot up its giving me "Error mounting settings partition" then reads under that "Persistent settings partition seems corrupt. Reformat?" If I reformat though it takes away any option to boot into any operating system that is on it and wont allow me to do anything.

kahlenberg
Posts: 41
Joined: Mon Jul 29, 2013 10:47 am

Re: time and date are incorrect

Tue Nov 05, 2013 12:07 pm

Hi again,
I solved the problem by changing the nameservers setings in the/etc/resolv.conf. I am connecting to my RPi from office computer via SSH, It was very surprising that the content of this file was completely wrong, nameserver entries were the IP numbers, from which I connect. I changed them to google DNS (8.8.8.8) and after rebooting the time and date are now correct! Maybe somebody will also need this solution.

Thanks for your helps.

ahmishgoma
Posts: 2
Joined: Thu May 22, 2014 8:19 pm

Re: [SOLVED] time and date are incorrect

Thu May 22, 2014 8:33 pm

Hi,

After you changed the nameserver settings to the google dns, did you also set the ntp servers in /etc/ntp.conf to google? Or are you using the pool.ntp.org servers?

I'm facing the same problem as you were. My time is just not syncing with the internet. If I use the ntpq -p command, I'm getting 0.0.0.0 in all the fields. I'm guessing this means that my raspberry pi isn't connecting to google?

I tried stopping my ntp and reconfiguring in raspi-config and restarting my ntp as mentioned in one of the replies above but that also doesn't work.

ytsentas
Posts: 2
Joined: Thu Jul 10, 2014 6:29 pm

Re: [SOLVED] time and date are incorrect

Thu Jul 10, 2014 6:32 pm

Below is a script that will retrieve the date from a free API. You can set this script to during boot in /etc/rc.local. This will resolve any issues.

Code: Select all

#!/bin/bash
# Visit http://www.timeapi.org to find the correct url for your timezone. Then replace the url in the first line

time=$(wget http://www.timeapi.org/utc/in+two+hours?format=%25d%20%25b%20%25Y%20%25I:%25M:%25S -q -O -)
echo "Time set to:"
sudo date -s "`echo $time`"

vr00m
Posts: 1
Joined: Mon May 25, 2015 9:24 am

Re: [SOLVED] time and date are incorrect

Mon May 25, 2015 5:23 pm

Keep in mind that it could take half an hour to even know if your current settings work; this was said on the site where I got the ntp servers list for my region.


Quote:
Start ntpd, and after some time (this could take as long as half an hour!), ntpq -pn should output something like:

avbidder:~$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+81.6.42.224 193.5.216.14 2 u 68 1024 377 158.995 51.220 50.287
*217.162.232.173 130.149.17.8 2 u 191 1024 176 79.245 3.589 27.454
-129.132.57.95 131.188.3.222 3 u 766 1024 377 22.302 -2.928 0.508

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: [SOLVED] time and date are incorrect

Tue May 26, 2015 3:25 pm

vr00m wrote:Keep in mind that it could take half an hour to even know if your current settings work; this was said on the site where I got the ntp servers list for my region.


Quote:
Start ntpd, and after some time (this could take as long as half an hour!), ntpq -pn should output something like:

avbidder:~$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
+81.6.42.224 193.5.216.14 2 u 68 1024 377 158.995 51.220 50.287
*217.162.232.173 130.149.17.8 2 u 191 1024 176 79.245 3.589 27.454
-129.132.57.95 131.188.3.222 3 u 766 1024 377 22.302 -2.928 0.508
He's had considerably more than half an hour, since the post you are replying to is almost a year old.
Doug.
Building Management Systems Engineer.

mh348
Posts: 2
Joined: Wed May 06, 2015 4:33 pm

Re: [SOLVED] time and date are incorrect

Thu May 28, 2015 8:10 pm

For those having this problem, check your DHCP Server, it looks like the ntp address that your dhcp server is issues might prevent the Pi from using the you you specified in the config file.

jitendra43
Posts: 11
Joined: Tue May 03, 2016 10:42 am

Re: [SOLVED] time and date are incorrect

Thu Jun 30, 2016 7:23 am

Hi ,

Hope you are doing well.

I would like to inform you that i am facing one issue related with Date and Time for a long time...problem is that i have raspberry pi 2 and some time its stop syncing date and time after 10 or 12 days automatically..i run date -s command for reseting and after that its fine but again after some days its automatically stop syncing as a local time zone and sometime when i run ntp service restart most of the time nothing happened with this command..only "date -s" work to reset. i have already check many time international timezone setting from "rasp-config" but there is everything ok " Asia, kolkatta".....so kindly let me know if any other way do you have to resolve this issue permanently.

Thanks in Advance,
Jitendra Yadav

kyoichi14
Posts: 1
Joined: Mon Aug 22, 2016 3:58 am

Re: [SOLVED] time and date are incorrect

Mon Aug 22, 2016 4:16 am

Hi All,
My date and time doesnt sync after boot. So I tried your suggestions here.
I did stop the ntp, changed my time zone and then started the ntp again (didnt work) and then used the date -s command
and restarted. It worked but after i unplugged the pi again my time is not synced but my date is already fixed.
I tried the $ntpq -p command and its telling me this

localhost: timed out, nothing received
***Request timed out

maybe this is whats preventing me from auto syncing? How do i go about and change this?

Thanks for your help

bodai
Posts: 7
Joined: Wed Feb 01, 2017 9:33 am

Re: [SOLVED] time and date are incorrect

Wed Feb 01, 2017 10:04 am

I moved home recently and my rpi does not any more have the right time. The move involved changing time zone and ISP and so the (ISP-owned) router. My rpi was powered down for about a week around the time of the move. When i first powered up after that, the time difference (error) was about that long, a week. I tried many of the things suggested above and elsewhere, as i detail below, but none worked: the dime difference remains, powering down the rpi and powering up after some time, the time difference increases by the amount of unpowered time. Please note that i'm not a computer/linux expert, and i don't understand in depth what i'm doing when i follow a suggestion.

The rpi seems to be on the internet, because i can

Code: Select all

ping www.google.com
and receive packages. Also, i received packages successfully running

Code: Select all

ping 1.gb.pool.ntp.org
where the address is that of a time server, appearing in my /etc/ntp.conf file.

I followed DougieLawson » Sun Nov 03, 2013 10:18 am
Start by shutting down ntpd with: /etc/init.d/ntp stop
Then use raspi-config to get the timezone set correctly (Option 4 change internationalization options from the main menu, then Option I2 set timezone from the submenu).
When ntpd starts it should do an initial sync with the time server to set the clock, but if your clock is off by too many days it won't work. So reset the clock with: date -s "3 Nov 2013 10:18:00"
Then restart ntp with: /etc/init.d/ntp start
but it didn't solve the problem.

I've also tried

Code: Select all

sudo service ntp stop
sudo ntpd -gq
sudo service ntp start
from http://raspberrypi.stackexchange.com/qu ... very-wrong
to no avail. This didn't work even if i set the time manually first, so that the error in time be not too much: having unpowered the rpi for a few minutes, i had that time difference -- clearly the correct time was not obtained from a time server after booting the rpi, but it was counted from the last known time before the latest shutdown.

When i run

Code: Select all

ntpq -p
the output is:

Code: Select all

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 192.168.178.1   .INIT.          16 u    - 1024    0    0.000    0.000   0.000

similar to that reported by kahlenberg » Sun Nov 03, 2013 10:45 am. I did notice the code 192.168.178.1 under

Code: Select all

, which look s like an IP address. In fact the local IP address of the router that i had before my move was just this. The local IP address of my new router is 192.168.0.1. Is it a clue to my problem?

I would much appreciate your help solving this problem. Thank you in advance.

User avatar
DougieLawson
Posts: 37111
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: [SOLVED] time and date are incorrect

Wed Feb 01, 2017 7:34 pm

Your network is broken. Start a new thread so we can discuss how to fix it.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “General discussion”