Is it possible to set the Linux clock with an RTC?

I'd like to have my Yun know what time it is without a network connection, and keep the time even after losing power. I have one of these RTCs, and I want the Linux side of my Yun to get data from it. Is there a way to tell Linux what time it is from my Arduino sketch? Is there a better way to make sure Linux always has the correct time without a network connection?

Process p;
p.runShellCommand("date -s \"2015-2-20 11:22:33\"");

You will, of course, have to format the string with the proper date and time from the RTC before making this call, so it’ll be a little more involved than this hard-coded example. But hopefully this gives you the idea. The format is “YYYY-MM-DD HH:MM:SS”

Ah. I didn’t realize the date command could set the time. That’ll work. Thanks.

Just looking back at what I wrote, it will probably work with single quotes around the date string, as well. If so, that will make the string a little cleaner without needing the backslashes before the internal quotes.

RTC is required setup correct time initially.

Using GPS to update RTC and then re-adjust RTC for current timezone.

Using long wave time signal/synchronize with atomic clock