5

Different commands about showing last reboot have different opinions. Who is right?

# uptime
 10:05:31 up 90 days, 12:59,  2 users,  load average: 0.04, 0.02, 0.00

# who -b
             system boot  2018-11-22 21:05
# last reboot

wtmp begins Sat Feb  2 01:59:42 2019

2 Answers 2

9

They are all correct.

  • uptime shows that the system has been up for 90 days and some hours.
  • who -b says the system was booted 2018-11-22 21:05 .. 90 days and some hours ago.
  • last reboot says that the wtmp log file was rolled over or trunctaded at Sat Feb 2 01:59:42 2019, so it don't contain a reboot record.
2
  • Thanx, I didn't get the last one though..
    – DimiDak
    Commented Feb 21, 2019 at 11:44
  • 1
    It is explaining that wtmp does not reach all the way back to the last boot. Commented Feb 21, 2019 at 21:43
7

The uptime command is telling you the current time, followed by the length of time the system has been running. In your example this shows the system has been up for 90 days, 12 hours and 59 minutes.

who -b is giving you a date and time that corresponds to the same boot time. There's only a difference of seconds there, which I presume is the time taken between commands.

The last reboot command uses the /var/log/wtmp file to determine the last boot. This log file has been rotated since the last boot took place, so does not contain information about the last boot. There is likely an old version of wtmp, such as /var/log/wtmp.1 that you can also query with:

last reboot -f /var/log/wtmp.1

Unfortunately it's unlikely that will contain details of your last reboot either due to the time frame.

2
  • Thanx, so what is "last reboot" good to use for?
    – DimiDak
    Commented Feb 21, 2019 at 11:45
  • 3
    It can tell you what the last reboot was, but it has to be recent enough that it's still available in the recent versions of the wtmp file. There must be a way to reconfigure how many wtmp files are saved. If you reboot your server now, then issue last reboot, it will show up in the output. The current output just means there are no recorded reboots in wtmp.
    – Arronical
    Commented Feb 21, 2019 at 11:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .