4

uptime -s shows when the machine was started:

sample output: 2020-12-31 03:24:00.

Is there a way to know the exact datetime when the machine was rebooted?

1 Answers1

7
last reboot | head -2

gives the last reboot times in a format like

reboot   system boot  5.4.0-58-generic Thu Dec 31 11:43   still running
reboot   system boot  5.4.0-58-generic Wed Dec 30 20:56 - 22:27  (01:30)

or use

last reboot --time-format full | head -2 | tail -1

to get something like

reboot   system boot  5.4.0-58-generic Wed Dec 30 20:56:16 2020 - Wed Dec 30 22:27:05 2020  (01:30)

or use something like awk to extract the end date

last reboot --time-format full | head -2 | tail -1 | awk -F ' - ' '{print $2}' | awk -F '(' '{print $1}'

-->

Wed Dec 30 22:27:05 2020  

https://www.cyberciti.biz/tips/linux-last-reboot-time-and-date-find-out.html

Koen
  • 1,277