Page 1 of 1

Need solution to set time & date by internet

Posted: Thu May 01, 2014 2:48 am
by leodh
Hi All,
I have tried searching all over the net and have not been able to find a solution to the time and date settings. I have tried to follow some of the examples, they do not work or assume some knowledge which I dont have and i get lost.

I would like to record time and date for some temp readings at a set time every day, that fine I can do that. But if the power goes off for more than 1000 seconds, on reboot the RPi will not update to the correct time.

1) how can I change that 1000 seconds to something larger (eg 1 day)
2) is there a way to force a time and date update within my Python program. ( regardless of time difference.

This type of question seems to be asked a lot but there does not seem to be a universl fix.

Any help would be greatly appreciated.
Thanks Leo

Re: Need solution to set time & date by internet

Posted: Thu May 01, 2014 3:11 am
by Richard-TX
apt-get install ntpdate

when you want to set the date

ntpdate time.nist.gov

Re: Need solution to set time & date by internet

Posted: Thu May 01, 2014 6:25 am
by rpdom
You haven't mentioned which OS you are using on your Pi.

If it is Raspbian, then it will have ntp installed which will set the time and date when it gets an internet connection.

It also has NTPD_OPTS='-g' set in /etc/default/ntp which means "ignore the 1000 seconds rule when you start up and just set the time anyway".

You shouldn't have an issue with that.

ntpdate will work, but is old and won't be supported for much longer.

Re: Need solution to set time & date by internet

Posted: Fri May 02, 2014 3:20 am
by leodh
Sorry about that I am using Raspbain, I have tried the ntpdate even that does not work.

I have looked at 'etc/default/ntp' and I can see that it has " NTPD_OPTS='-g' " already.

Is there away to programatically ( in python ) stop the sevice ntp, ntpdate xxx.xxx.xxx.xx and then start the service agian.
Thanks again
Leo