Set clock on Arduino Yún

In my Arduino Yún project, I’d had the problem of sometimes writing to the log file before the clock had been set (so the log had the wrong date and time). To avoid this, I wanted to force the clock to be set as part of my Arduino sketch.

After poking about on the Linino side of the Yún, I figured it out.

You use ntpd, like this:

p.runShellCommand("ntpd -qn -p");

I figured this out by ssh-ing to the Yún and using ps to see what processes were running. I figured I might be looking for ntp, so I used

ps | grep ntp

I don’t know why the command uses the 0. in, but didn’t work, and the command I saw running in the results from ps used it.


Tags: , ,

4 Responses to “Set clock on Arduino Yún”

  1. Mark Says:

    Doesn’t work on my YUN – get’s a syntax error.

  2. Mark Says:

    Thanks Karl!
    That was just the solution I was looking for to the same problem.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s