4

It looks like the ntpd doesn't get the correct time with WiFi. My Raspberry Pi's are connected via WiFi dongles (which work without problems) to my network. The odd thing is, I read that the time should be on "Jan 1, 1970" if it doesn't work correctly. But my time is always on "Jun 13, 2013"...

When I perform the command:

sudo dpkg-reconfigure ntp

or wait for a while it gets the right time. Maybe the ntpd starts before the WiFi has connected successfully? Can I change this in an easy way?

I found something similar, but it was for Arch Linux which doesn't help me.

  • The Pi saves the current time and date right before it shuts down, and restores this time when it starts up again. This way, the next time it boots up, the time will, let's say, less inaccurate. It's called fake-hwclock. That would explain your Jun 13, 2013 observation. – Gerben Aug 1 '13 at 19:42
3

You could add that command (sudo dpkg-reconfigure ntp) to the bottom of .bashrc. That way, every time you log in the time will be updated (assuming the WiFi device is connected to the Raspberry Pi and running properly).

  1. Make sure you are in the pi folder: $ cd ~
  2. Open up .bashrc for configuration: $ sudo nano .bashrc
  3. Scroll down to the bottom and add the line sudo dpkg-reconfigure ntp
  4. Exit and save: Ctrl+X, Y, Enter

If you are looking for a solution that works on bootup, take a look at this link. Basic rundown:

  1. Create a file for your startup "script": $ sudo nano /etc/init.d/scriptname
  2. Add the line sudo dpkg-reconfigure ntp to your file.
  3. Exit and save: Ctrl+X, Y, Enter
  4. Make the "script" executable: $ sudo chmod 755 /etc/init.d/scriptname
  5. Register script to be run at start-up: $ sudo update-rc.d scriptname defaults
  • Can't I do this on the Raspberry Pi in a global solution? This way it will only have effect if I log in with the user pi? – Dominik Jul 31 '13 at 20:36
  • I've edited a link into the answer for running a command on startup. Take a look there. – syb0rg Jul 31 '13 at 20:39
  • 1
    Since I extended the script with the dependencies $all so it will definitely performed after the wifi is setup correct I had to use the command insserv instead of update-rc.d but now it works. thanks! – Dominik Jul 31 '13 at 21:34
  • 1
    @Bagorolin: It would be very helpful to people who come after you if you were to document the whole procedure, including the full commands such as insserv, in an answer to your own question. Thanks. – dotancohen Aug 1 '13 at 13:11
  • @dotancohen how do i make code blocks if there is an "#" at the beginning? I can't find something in the help site. And unfortunately I don't have so much time to look for this.. – Dominik Aug 1 '13 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.