30

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?

Jjed
  • 13,714
  • 10
  • 63
  • 91
Selvakumar
  • 301
  • 1
  • 3
  • 3

2 Answers2

51

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).

muru
  • 193,181
  • 53
  • 473
  • 722
wojox
  • 11,152
  • 5
  • 40
  • 60
  • great answer, I add | tail -10 – enzotib Apr 26 '11 at 19:05
  • 1
    I have no `/etc/default/bootlogd` on my Ubuntu 16.04.2 – Vadim Kotov Oct 24 '17 at 14:58
  • More on [how to enable bootlogd](https://wiki.debian.org/bootlogd), which is not necessary as of Debian Wheezy ([i.e. as of Ubuntu 11.10](https://askubuntu.com/questions/445487/what-debian-version-are-the-different-ubuntu-versions-based-on) -- or so seems likely). – mathandy Feb 17 '18 at 00:24
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
WinEunuuchs2Unix
  • 99,709
  • 34
  • 237
  • 401