2

I want know the boot and shutdown date of my laptop on last friday:

===> last reboot
reboot   system boot  4.4.0-47-generic Mon Nov 28 09:39   still running
reboot   system boot  4.4.0-45-generic Fri Nov 25 09:40 - 15:55  (06:14)

According to this output the laptop was switched on from 9:40 to 15:55.

see this in my bash history. The shutdown times match:

===> history | grep 2016-11-25| tail
24911  2016-11-25 15:51:33 :... some command

But the start time does not:

===> history | grep 2016-11-25| head
24850  2016-11-25 08:58:35 :ssh somehost
24851  2016-11-25 08:47:01 :...

I think there is something wrong.

I checked my boot/shutdown times with a different tool the last 5 days, and this reveals: The output of last reboot is wrong. Every day one hour is missing.

Do your time of last reboot match?

Update, two years later, I found the solution: https://serverfault.com/a/958823/90324

  • 1
    Add the full output of last reboot – heemayl Nov 30 '16 at 12:46
  • Can't say for certain, but it seems likely the system applies a DST or zone correction sometime after the reboot time is written to the log. This is especially likely if the start time is off one hour, but the shutdown is correct. FWIW, my desktop system (Kubuntu 14.04.5) routinely displays a time in the tray clock that's off by a non-integer number of hours immediately on desktop load, but corrects it before the desktop finishes fully initialization (i.e. all tray icons present and CPU usage drops to idle). This is what suggests the late DST/zone correction. – Zeiss Ikon Dec 8 '16 at 12:24
  • Here is the solution: serverfault.com/a/958823/90324 – guettli Mar 21 '19 at 12:48
2

Probably your hardware clock is in UTC. And maybe your system is in CET. Therefore when you boot your computer, the first log entries will be in UTC.

| improve this answer | |
1

I personally prefer to use the kernal logs to find out when a system was turned off and on again, simply because it's far more verbose than the output of last reboot, though you'll need to scan over the log files to find what you're after (I usually grep through them) .

They can be found in /var/log/, and should look similar to this:

-rw-r-----  1 syslog            adm    181476 Nov 30 18:34 kern.log
-rw-r-----  1 syslog            adm    185878 Nov 29 16:42 kern.log.1
-rw-r-----  1 syslog            adm     46081 Nov 21 20:05 kern.log.2.gz
-rw-r-----  1 syslog            adm     41326 Nov 14 18:19 kern.log.3.gz
-rw-r-----  1 syslog            adm     16143 Nov  8 20:32 kern.log.4.gz

Your history command simply shows the command line history, and thus is inherently a flawed source of shutdown/start/reboot data, in that you may not have run a command right before you shut down the machine (if you used the GUI to shut down).

| improve this answer | |
  • Your answer right. But, it is an answer to a different question. This question is about: last reboot is missing one hour. But I am curious. How to get the boot/shutdown times from /var/log/kern.log? – guettli Dec 12 '16 at 9:01
  • Yeah I wasn't sure on the answer to your specific question, but instead thought to offer an alternative way to measure the reboot times. I'll keep digging though, see if I can figure it out! In the meantime, kern.log files use timestamps to show time since boot (or uptime). You would usually see something like this – The Pizza Overlord Dec 12 '16 at 9:35
  • Whoops, entered comment before finishing it. Anyway, you'd see something like this in the kern.log files that basically shows up-time at zero, or, commonly interpreted as the boot time: [ 0.000000] . If you grep through for that, you should be able to work out the boot times. – The Pizza Overlord Dec 12 '16 at 9:37
  • Can you please reveal the grep magic to work out the boot times? – guettli Dec 12 '16 at 10:11

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.