Linux boot time

Question

When was my Linux machine last restarted?

Environment

RHEL 7

Answer

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

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)  
 Note
If there is a discrepancy between the times shown by various methods, run the command  sudo timedatectl set-local-rtc 0

Details

Article ID: 1623
Created
Wed 5/27/20 8:28 AM
Modified
Mon 10/19/20 12:06 PM