Newsletter Subscribe
Enter your email address below and subscribe to our newsletter
There are multiple reasons why one would want to check when the Linux server was rebooted. For example, checking the last reboot time of a Linux server is crucial for troubleshooting, as it helps identify if issues began after a reboot due to recent changes.
The easiest way to check when the Linux server was last rebooted is to use the who command as shown here:
who -b
As you can see, it shows the last reboot time when your system was booted.
In this tutorial, I will walk you through four ways you can find when a Linux server was last rebooted:
Let’s start with the first one.
Table of Contents
The last command is the most useful tool to find when the system is rebooted as it offers multiple flags to fine-tune the output. The simplest way to check the system reboot history is by using the last reboot command without any flags and it will display all the reboots in reverse chronological order:
last reboot
Each line shows a reboot event, including the date and time of the reboot, and if applicable, the duration for which the system was running before being rebooted again.
Apparently, you can limit the number of entries displayed by using the -n option followed by the number of entries you wish to see:
last reboot -n <number-of-lines>
For example, if I want to check entries for the last five reboots, then I will use the following command:
last reboot -n 5
The uptime
command is one of the simplest ways to check how long a system has been running since the last boot. It provides a quick snapshot of the current time, how long the system has been up, how many users are currently logged on, and the system load averages.
To get the exact boot time, you will need to execute the uptime
command with the -s
flag as shown here:
uptime -s
If you want more detailed output, you can execute the uptime
command without any additional flags:
uptime
Here’s a breakdown of what each part of this output means:
The who command in Linux is used to find the logged-in users but when you pair it with the -b
flag, it can show you the last boot time as well:
who -b
Here’s a detailed explanation of what this output means:
Note: The uprecords utility will start counting the reboots after you install the uprecords. This means you can not access reboot records prior to the system state when uprecords was not installed.
The uprecords
utility does not come pre-installed and to use this utility, you need to install a package called uptimed
. If you are using a Debian-based distro, then you can use the following command to install it:
sudo apt install uptimed
Once done, you can run the uprecords
utility as shown here:
uprecords
Here’s a breakdown of each section:
0 days, 09:15:58
indicates that the system was up for approximately nine hours and sixteen minutes.Wed Oct 2 at 11:07:50, 2024
.->
), showing the current uptime session.0 days, 00:00:50
, meaning the system has been up for just fifty seconds since the last boot.Wed Oct 2 at 20:24:08, 2024
.uptimed
, which is 0 days, 09:16:48
.0 days, 00:00:20
.99.940%
.If you want to sort by the newest records first, you can use the -B
flag with the uprecords
command as shown here:
uprecords -B
Alternatively, if you want to sort by oldest boots first, then you’d need to pair the uprecords
command with the -b
flag as shown here:
uprecords -b
In this tutorial, I went through four methods to determine the last reboot time of a Linux server, which is crucial for troubleshooting. The last reboot command displays all reboots in reverse chronological order and can be limited to show a specific number of entries.
The uptime command provides a snapshot of how long the system has been running since the last boot and can show the exact boot time with the -s flag.
The who -b command directly shows the last boot time, including both date and time. Lastly, the uprecords utility, which requires installation, tracks uptime records from its installation point and provides detailed information on boot times and uptime durations. I personally find the last method more useful and interactive to use.