How to Check Uptime of Your Linux Server
Stop wondering how long your system has been running. Just check its uptime with uptime command.
β Abhishek Prakash
The uptime command in Linux is used for finding how long the Linux system has been up and running.
It is one of the simplest Linux commands. Just run it without any options:
uptime
This will show you a single line of output that shows the current time, the uptime (in days and hours), the number of users currently logged on to the system, and the load average.
Here's a sample output of the uptime command:
abhishek@LHB:~$ uptime
16:13:00 up 2 days, 8:18, 1 user, load average: 1.19, 1.54, 1.51
You can probably identify the uptime but let me explain all the elements of this output.
- 16:13:00: This is the current time on the system.
- up 2 days, Β 8:18: This means the Linux system has been running for the last 2 days, 8 hours and 18 minutes.
- 1 user: This is the number of users currently logged into the Linux system.
- load average: 1.19, 1.54, 1.51: This gives the average CPU load for the past 1, 5 and 15 minutes. 1.54 means that 154% of the CPU consumption (if it's a 4-core CPU, it means 1.54 out of 4 cores were in use).
The uptime command gets the boot related information from the /proc
files like most other commands. It uses the /var/run/utmp
file to get the information on the logged-in users.
It's not that uptime doesn't have any option at all. There are only a few but could be useful in some cases.
Using uptime command with options
If you think the output of the uptime command is too cluttered, you can use the pretty print option -p
:
uptime -p
It will show just the uptime information, that too in words, which is more understandable.
abhishek@LHB:~$ uptime -p
up 2 days, 8 hours, 47 minutes
If you want to know since when the Linux server is running, you can use the option -s
:
uptime -s
It will give the exact timestamp when your system booted the last time:
abhishek@LHB:~$ uptime -s
2022-02-14 07:54:21
There is also option -V
that shows command version and -h
for showing the help page.
Bonus Tip: Keep a record of your uptimes
The uptime command only shows how long your system has been running.
There is a handy utility called uprecords
that provides the record of your uptimes.
No kidding! It shows the best (longest) uptimes of your Linux system in a tabular format with additional information about the boot time, duration and Linux kernel version.
This uprecords
command is not installed by default. It is available in the package called uptimed
and you have to install it on your system.
On Debian/Ubuntu, you can use:
sudo apt install uptimed
It's basically a daemon that tracks a system's highest uptimes via boot IDs, using the system boot time to keep sessions apart from each other.
Once uptimed
is installed, you can use the uprecords
command to show the uptime records:
uprecords
Keep in mind that you won't get historical uptime records straightaway. It starts recording since the time uptimed daemon is installed.
Now that you know how to check Linux server uptime, watch and listen to this fantastic song called Uptime Funk (parody of Uptown Funk):
So, when was the last time you restarted your Linux server.
Creator of Linux Handbook and It's FOSS. An ardent Linux user & open source promoter. Huge fan of classic detective mysteries from Agatha Christie and Sherlock Holmes to Columbo & Ellery Queen.