How do I find the last logged system boot and shutdown times?

I'm a Rails developer working on a web application on Ubuntu Server 10.04. Due to internal requirements, I was asked to find the last 10 system boot and shutdown times... I have no clue where to find these details. Could someone help me out?


Solution 1:

Use the last command.

last -x | grep shutdown
last -x | grep reboot

You can pipe this to the head to read the last n instances. For example, in your case:

last -x | grep shutdown | head -n 10

You also should set

BOOTLOGD_ENABLE=Yes

in the /etc/default/bootlogd file (it could be No by default).

Solution 2:

For a GUI method you can use hardinfo as described here: Does Ubuntu have a "device manager" equivalent? And what is an easy way to access USB drives?.

Under the section Boots you will see this:

Hardinfo boot log.png

Installation is straight forward using:

sudo apt install hardinfo