There are several ways to find the uptime of a Linux server. Some of the most common methods are:
uptime
command: The uptime
command is a simple and easy way to find the uptime of your Linux server. Just open a terminal and run the uptime
command to see the uptime of your server. The output will show you the current time, the number of users currently logged in, and the length of time that the server has been running. For example:$ uptime 20:12:34 up 12 days, 18:50, 1 user, load average: 0.00, 0.00, 0.00
/proc/uptime
file: The /proc/uptime
file is a special file in the Linux filesystem that contains the uptime of the system in seconds. You can use the cat
command to view the contents of this file and find the uptime of your server. For example:$ cat /proc/uptime 1050.49 1048.12
The first number in the output is the uptime of the system in seconds.
who -b
command: The who -b
command shows the last system boot time. You can use this command to find the uptime of your server by subtracting the boot time from the current time. For example:$ who -b system boot 2020-09-01 19:34 $ date Tue Sep 13 20:12:34 UTC 2022
To find the uptime in seconds, you can use the date
command to get the current time, and subtract the boot time from it. You can use the awk
command to perform the subtraction and convert the result to seconds. For example:
$ awk '{print $1 - strftime("%s", $3)}' <(who -b) <(date) 982800
These are some of the ways that you can find the uptime of a Linux server. Consult the documentation of the commands and the online resources available for more information on how to use these tools and the various options and features available.