Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If I was looking through a debian log file and I come across Jan 1st 1970 08:21:34 in a log, did the action happen at 08:21:34, just the correct date had not been set? Or if no date had been set is the time wrong too? Is there any way to verify?

My eventual aim is to establish how long my installation took but the first records in my log have the year 1970...

share|improve this question
add comment

2 Answers

You can't really rely on the absolute value of the timestamp if you don't know if it was recorded as UTC or in your local timezone, and you can't really rely on it at all if you don't when/how/if the clock was reset.
(A completely reset clock will bring you back to 01/01/1970 00:00 UTC.)

The time difference between the first and last records on the other hands should be reliable (if you don't care about to-the-second accuracy - clocks on PC are usually terrible for accurate time accounting, and judging by the date you didn't have ntp running yet).

If your records jump from the '70s to the modern era at some point, calculate the time difference for the "old" timestamps, then the time difference for the "new" ones. The gap should correspond to the time it took to properly set the clock, which isn't much wall-clock time.

share|improve this answer
add comment

Time and date are only separate for humans. The system keeps only a count of seconds, and divides by 86400 for display purposes.

If you see Jan 1st 1970 08:21:34 and the timezone is UTC, it means that the machine cold-started with no external time source 8 hours and 20-odd minutes ago. It's quite possible that this date is in some other timezone; for example, in Japan (JST), this date indicates a machine that booted 20 minutes ago.

In any case, the time shown is not indicative of the real time, any more than the date is indicative of the real date. Not unless you booted at precisely midnight.

If your machine lacks a hardware clock that keeps the time while powered off, and it has a network connection, use ntpdate to retrieve the time via NTP.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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