Keeping 'order' without RTC.

Feb 28, 2015 192 Replies

If you had paid any attention to the complete problem you'd know there's no way to enter the time on power up. Think of this as a home-brew ipod nano with no buttons save power on/off.

Please, just butt out of you have nothing to offer. You're worse than the so-called troll. Same for the rest of ya, there's more blather by you folk whining or being super-superior about the "troll" than actual technical discussion about anything. Just shut up already. You think you're so superior when you're just feeding the fire to get your own names up in lights.

If you want time and date to be meaningful - which may or may not be the case you have to ensure that they are accurate.

There are three ways to do that -

- a battery backed clock that keeps time when the 'puter is off.

- use of some internet accessible clock that you trust to set time on boot and keep time after boot

- manually or magically setting the clock to the correct time on boot.

If none of those suit your bigotry, then go away. Posing problems that have no acceptable solutions is even easier than dreaming up solutions that are totally impractical.

See the Belling Of The Cat.

Everything you read in newspapers is absolutely true, except for the rare story of which you happen to have first-hand knowledge. ? Erwin Knoll

The OP said, specifically, that he only wanted to keep "order". For that purpose the time and date don't have to be meaningful.

Keeping order does have another practical solution. It is only necessary to set the date and time to a value greater than the latest date and time that was last used.

which any simple script can do.

using the mtime of some logfile that records 'shutdown' as the 'last menaingful timestamp'

Everything you read in newspapers is absolutely true, except for the rare story of which you happen to have first-hand knowledge. ? Erwin Knoll

No, I've been paying attention for years to this kid's postings. He comes up with a nominal problem, gets replies, but since he defined the problem wrong, he never gets a "suitable" answer, not that he really is looking for an answer.

I replied once, then ignored the thread. Then it gets resurrected, and the stupid subject header "Keeping 'order' without RTC" is back staring at me. There's a "real time clock" it's inherent to the way Linux works.

If he can't even get that right, then who's to believe any further problem he claims to have?

If you have an actual question along these lines, then ask, don't rely on some fool to ask the question for you.

Michael

On Mon, 13 Apr 2015 16:22:36 -0400, Michael Black declaimed the following:

Based on the Wikipedia entry -- "real time clock" matches my interpretation of such... An independent, battery-backed, source of "wall clock" time -- not a processor interrupt that counts in some fraction of wall-clock units but stops running when the power goes away.

Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

Set up a cron job to touch a file every minute. At bootup set the system clock to one minute after the mtime on the touched file (check the file before cron touches it). Your system time will then always be monotonically increasing and your timestamps will always be in the correct order.

John Hasler jhasler@newsguy.com Dancing Horse Hill Elmwood, WI USA

It doesn't exactly say battery-backed.

RTCs often have an alternate source of power, so they can continue to ^^^^^ keep time while the primary source of power is off or unavailable. This alternate source of power is normally a lithium battery in older systems, but some newer systems use a supercapacitor, because they are rechargeable and can be soldered.

I don't know if I read that as a RTC must be either a capacitor or battery. Another alternative is just a counter where you set the start time manually or from the internet.

Like the clock on a microwave oven or the clock on a cable box.

Dan Espen

Yes it can. None of mine have an RTC.

You can buy one on eBay for a few dollars.

And you wasted a lot of time because you don't know what an RTC is. Hint: it isn't the software clock maintained by the OS.

In fact, the Rasperry Pi already has that. It is called fake-hwclock.

But it apparently is not sufficient for the hypothetical use case.

If the RPi has a network connection the lack of a battery-backed RTC is somewhat irrelevant. You just install ntpd, the NTP time server, and configure it to start at boot time. On booting the RPi shows a date and time that is obviously a continuation from the dat and time when when it was last halted. It seems ntpd to take 2 - 3 minutes after the RPi was booted to get the correct time from its configured list of time sources and to reset the RPi's time source.

So, using NTP in this way would do everything the OP wanted *provided that the RPi has a working network connection*. From re-reading the OP's initial posts it looks if this may not be the case.

However, as this may not matter because an RPi running Raspbian appears to automatically set its clock to the time and date of its last shutdown when it boots.[1]

This is good enough to meet the OP's stated requirement by including the timestamp in his filenames. [1] I haven't tested this without a copy of ntpd installed, but the observed behavior is consistent with this and is trivial to test on an RPi that doesn't have ntpd set up: I simply ran 'date' every 30 seconds or so. Initially it showed the time continuing from when I'd stopped the RPi last night and after 2-3 minutes to time stepped forward to match the laptop I'm using to write this.

martin@ | Martin Gregorie gregorie. | Essex, UK org |

Everything you read in newspapers is absolutely true, except for the rare story of which you happen to have first-hand knowledge. ? Erwin Knoll

Which is also the Linux interpretation. The periodic interrupt is just called the clock or timer.

Sorry, you are confused. RPi runs with a system clock. But it has no Real Time clock (RTC) unless you add a harware dongle. Yes, the RPi keeps time. But it starts out at Jan 1 1970 each time you reboot.

The hardware clock as you call it has been called the Real time clock since the first IBM PC.40 years ago.

Your suggestion that every time the computer is switched on the operator enter in the correct time by hand is certainly one possibility. But computers are supposed to make life easier, not add yet another task, which is sometimes impossible (eg the RPI is floating over the Pacific in a balloon and it resets due to a power interruption).

So, please do not get so self righteous.

On Tue, 14 Apr 2015 23:18:39 +0000 (UTC), William Unruh declaimed the following:

If you have a unit "floating over the Pacific in a balloon" I'd hope you also have a GPS receiver and a telemetry beacon transmitter... The receiver would provide a time signal, and the transmitter would provide real-time tracking capability to a ground stations.

Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

You are literal aren't you. Fine--- 1000 meters down a coal mine instead. And no there need not be any telemetry capability-- just a visit once a month. It is not true that simply having the operator enter a time and date at startup is a trivial solution to the problem.

Yes solutions are possible, but often not that one.

-> > The hardware clock as you call it has been called the Real time clock

-> > since the first IBM PC.40 years ago.

-> Actually the first IBM PC _didn't_ have a real time clock, that

-> only came in slightly later, either the XT or AT. If you ever ran The IBM AT was the first computer to be shipped with a realtime clock. Though, the XT could get an ISA adapter card that would provide the realtime clock features to the XT using a small program that would read the time from the time clock and set the XT's clock from that reading.

In which case he needs to set a time that is higher than the last access time on any file in the file system. If he uses ext3, 4, xfs or jfs then there is journalling, and the file system is in a consistent state when you get tl execute something late in the boot process, like rc.local.

The find/awk/ls/sort script to do this is left as an exercise to the reader. (find most recently accessed file, do a stat on it, and set the system time to 30 sec in the future from that.)

If the OP _really_ needs this I can see what I can dig up. I used to do this on an altos machine way back before NTP.

-- mrr

There is a fourth way, if all he wants is a montonically increasing time, not necessarily connected with time in other parts of the universe.

Which is what I interpret him to want.

-- mrr

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required