This forum is in archive mode. You will not be able to post new content.

Author Topic: [SOLVED] Fix time on Raspberry Pi with ArchLinux-on-ARM  (Read 2123 times)

0 Members and 1 Guest are viewing this topic.

Offline flowjob

  • Knight
  • **
  • Posts: 327
  • Cookies: 46
  • Pastafarian
    • View Profile
[SOLVED] Fix time on Raspberry Pi with ArchLinux-on-ARM
« on: April 12, 2014, 03:18:15 PM »
After googling for days, I gave up and just decided to ask you guys, as I know that a few of you have a pi...

I've installed Arch on ARM on my raspberry, and since haven't been able to get the time working...
As the raspberry pi has no hardware clock, the time is reset to 1970 everytime I reboot it, wich causes problems with some certificates and such.

I'm just going to tell you what I've tried, and what I found out so far:

ntpd -gqd (obviously w/o the service running)
ntp starts, but does neither change the time (-g: big changes), nor does it exit (-q:change time, then quit), instead it just keeps running printing:
Code: [Select]
SOME_DEBUG_INFO...
transmit: at SOME_GROWING_NUMBER 10.0.0.2->SOME_IPS mode 3 len 48
I've even left it running for 2 hours once, kept printing the upper  transmit message the whole time...

Using ntpd.service
The service starts when booting without any error, but the time isn't changed, instead it is still 1970...
I also checked the .service file, and in ExecStart ntpd is also executed with the -g parameter, but the time isn't changed.

ntpdate
Is deprecated, ntpd -gq should be used instead, but that does not work either.
Leaves with the following error message:
Code: [Select]
1 Jun 1:04:27 ntpdate[691]: no servers can be used, exiting
ntpdate -u 0.europe.pool.ntp.org
This actually changes the time to the current time in my timezone, but is lost after reboot, as there is no hardware clock.


The last command worked, but I couldn't get it to work with a systemd service...

I tried adding
Code: [Select]
ExecStartPre=/usr/bin/ntpdate -u 0.europe.pool.ntp.org to ntpd.service under [Service], but the service fails at boot, saying ntpdate exits with error-code failure when checking with
Code: [Select]
systemctl status ntpd.service
I also wrote a seperate service, wich would be start after dhcpcd.service is successfully running (so that I have a working internet-connection) using
Code: [Select]
Requires=dhcpcd.service
After=dhcpcd.service
under [Unit], but again the service fails at boot, saying ntpdate exits with erro-code failure...


I don't have any idea, why ntpdate exits with error-code failure when executed in a systemd service...
The internet connection shouldn't be the problem, as ntpd.service is working fine...
Any ideas what the problem could be? And how to fix this?
« Last Edit: April 12, 2014, 04:21:49 PM by flowjob »
Quote
<phil> I'm gonna DDOS the washing machine with clothes packets.
<deviant_sheep> dont use too much soap or youll cause a bubble overflow

Offline flowjob

  • Knight
  • **
  • Posts: 327
  • Cookies: 46
  • Pastafarian
    • View Profile
Re: [SOLVED] Fix time on Raspberry Pi with ArchLinux-on-ARM
« Reply #1 on: April 12, 2014, 04:25:57 PM »
It seems that ntpd can be started without a working internet connection, but I found a fix:
Add the following two lines in ntpd.service before ExecStart:
Code: [Select]
ExecStartPre=/usr/bin/bash -c "while true; do ping -c 1 8.8.8.8 &> /dev/nullv && break; done"
ExecStartPre=/usr/bin/ntpdate -u 0.europe.pool.ntp.org
The first line only finishes if there is a working internet connection. This also means that if theres no connection, the NTP daemon won't be started, but you won't need it anyway, if you can't sync the time...

Note:
Kinda classic that I come up with a fix short after posting a thread, after I searched for days...
Quote
<phil> I'm gonna DDOS the washing machine with clothes packets.
<deviant_sheep> dont use too much soap or youll cause a bubble overflow

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: [SOLVED] Fix time on Raspberry Pi with ArchLinux-on-ARM
« Reply #2 on: April 13, 2014, 03:59:17 PM »
If you wanted a hardware solution, you could use a RTC module.

http://www.buyapi.ca/product/rasclock-raspberry-pi-real-time-clock-module/
>>>import this
-----------------------------

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.