Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: onelife on November 12, 2013, 09:41:19 AM

Title: getTime.sh / ntp
Post by: onelife on November 12, 2013, 09:41:19 AM
Hi Guys,

I'm trying to solve the getTime.sh / ntp issue.

Currently here in South Africa the getTime.sh script does not work :(

Does anyone know how you can use getTime to access a local network ntpd server.

I have a ntp server on the network so ideally I would like to access that.

I've tried using the different "switches" -s for local and / or simply the address 192.168.1.3 with wait -w 20 but no luck.

Do you know if the getTime.sh script will actually talk to a "normal" ntpd server?

Also, another thought - It would be great if there was a way to "save" the system time at point of reboot. IOW, perhaps a way you "pipe" the date into a file and then on start, re-read the date initially from that file before even trying getTime.sh? Just a thought as that would help me on reboot when no internet is available on start up. (I know this means there will be a discrepancy in the time it takes to reboot, but this I can live with rather than the default 1970 date that gets set on startup)

Thanks in advance and chat soon :)
Title: Re: getTime.sh / ntp
Post by: tinypoodle on November 12, 2013, 02:05:47 PM
Do you know if the getTime.sh script will actually talk to a "normal" ntpd server?
No, it's making use of 'daytime' (port 13).
Quote
Also, another thought - It would be great if there was a way to "save" the system time at point of reboot. IOW, perhaps a way you "pipe" the date into a file and then on start, re-read the date initially from that file before even trying getTime.sh? Just a thought as that would help me on reboot when no internet is available on start up. (I know this means there will be a discrepancy in the time it takes to reboot, but this I can live with rather than the default 1970 date that gets set on startup)
Simply setting system time according to some external clock with the 'date' command seems like a lesser evil IMHO.
Title: Re: getTime.sh / ntp
Post by: onelife on November 13, 2013, 03:04:31 AM
Heyo

Thanks for the reply - Sadly I don't have a RTC on the Pi (Yet) ... Am looking into this and will likely happen in the next few months BUT I really need to try solve the time / date issue now for a few systems I already have.

Do you know what it would take to get a ntp client working on PiCore? I see there is a tcz for the "standard TC".

Thanks again.
Title: Re: getTime.sh / ntp
Post by: bmarkus on November 13, 2013, 03:28:24 AM

Do you know what it would take to get a ntp client working on PiCore? I see there is a tcz for the "standard TC".


1) Wait a bit
2) Create yourself

:)
Title: Re: getTime.sh / ntp
Post by: tinypoodle on November 13, 2013, 06:22:41 AM
A temporary remedy could be to download a statically linked busybox binary which should include ntpd from here:
http://busybox.net/downloads/binaries/latest/

Something like
Code: [Select]
sudo busybox-i686 ntpd -ndqp time.nist.govworks for me, obviously tested with x86 though.
Title: Re: getTime.sh / ntp
Post by: tinypoodle on November 13, 2013, 06:47:01 AM
Another quick method could be:
Code: [Select]
sudo rdate some.time.serverAt least in Core x86 rdate is included in base already, so no need to install anything.
Title: Re: getTime.sh / ntp
Post by: bmarkus on November 13, 2013, 11:51:59 AM
ntp is running here on the Pi, I will add it to repo in a day.
Title: Re: getTime.sh / ntp
Post by: ovacikar on December 29, 2023, 10:43:35 AM
For anyone landing on this page via Google etc, there is a simpler way of setting the time using any web server with curl and busybox:

sudo busybox date  -D '%d %b %Y %H:%M:%S' -s "`curl -ks --head https://8.8.8.8 | grep '^Date:' | cut -d' ' -f 3-6`"
Title: Re: getTime.sh / ntp
Post by: curaga on December 29, 2023, 11:42:10 AM
I don't think you need curl, you can send a HEAD request using nc.
Title: Re: getTime.sh / ntp
Post by: patrikg on December 29, 2023, 02:26:40 PM
Or even use busybox wget ??

Code: [Select]
./busybox wget -q --spider -S --no-check-certificate https://dns.google
Title: Re: getTime.sh / ntp
Post by: ovacikar on December 29, 2023, 02:57:35 PM
Or even use busybox wget ??

Code: [Select]
./busybox wget -q --spider -S --no-check-certificate https://dns.google

Needed to redirect stderr to stdout, and readjust the spacing:

sudo busybox date  -D '%d %b %Y %H:%M:%S' -s "`busybox wget -O - --spider -S  --no-check-certificate https://dns.google  2>&1 | grep 'Date' | cut -d' ' -f 5-8`"
Title: Re: getTime.sh / ntp
Post by: patrikg on December 29, 2023, 04:42:40 PM
And you can even use the more modern way without using the backtick characters.

Code: [Select]
sudo busybox date -D '%d %b %Y %H:%M:%S' -s "$(busybox wget -q -O - --spider -S --no-check-certificate https://dns.google 2>&1 | grep 'Date' | cut -d' ' -f 5-8)"