Issue
This article discusses how to determine when a Linux machine was last restarted or rebooted.
Environment
RHEL, Ubuntu
Resolution
It is reasonable to expect all of these commands to give very nearly the same answer:
who -b
uptime -s
ls -ld /proc/1
last reboot | head -1
However, sometimes they don't. The difference is most likely the delta between local time and UTC. The best answer (in UTC) will be from uptime -s
.
For example, on a server last booted at 6:24am EST (UTC-0400) on December 17, 2018:
% who -b
system boot Dec 17 06:24
% uptime -s
2018-12-17 10:24:11
% ls -ld /proc/1
dr-xr-xr-x. 9 root root 0 Dec 17 06:24 /proc/1
% last reboot | head -1
reboot system boot 3.10.0-957.1.3.e Mon Dec 17 06:24 - 10:19 (49+03:55)
Please note: If there is a discrepancy between the times shown by various methods, run the command sudo timedatectl set-local-rtc 0
.