How To Check System Uptime in Linux

This post will guide you how to check the uptime using a command in your Linux operating system. How do I find the last reboot time in Linux.

How To Check System Uptime in Linux1

Uptime Command


Uptime gives a one line display of the following information. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

The syntax of the Uptime command is as follows:

uptime [options]

Options:

-p, --pretty show uptime in pretty format
-h, --help display this help text
-s, --since system up since, in yyyy-mm-dd HH:MM:SS format
-V, --version display version information and exit

W Command


w displays information about the users currently on the machine, and their processes. The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

They syntax of the W command is as follows:

w [options] user [...]

Top Command


The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel. The types of system summary information shown and the types,order and size of information displayed for processes are all user configurable and that configuration can be made persistent across restarts.

Checking System Uptime using Uptime Command


You can use the uptime command to find your Linux system’s uptime, type:

$ uptime

Outputs:

[[email protected] ~]$ uptime
07:17:31 up 73 days, 21:47, 1 user, load average: 0.00, 0.05, 0.06

From the above output, you can get the current time value (07:17:31), and how long the ystem has been running (73 days, 21 hours and 47 minutes). How many user are curretly logged on(1 user) and the system load averages for the past 1,5,and 15 minutes.

If you want to show your system’s uptime in pretty format, and you can pass the -p option to the uptime command, type:

$ uptime -p

Outputs:

[[email protected] ~]# uptime -p
up 10 weeks, 3 days, 21 hours, 47 minutes

If you want to find out the system up since in yyyy-mm-dd HH:MM:SS format, and you can pass the -s option to the uptime command, type:

$ uptime -s

Outputs:

[[email protected] ~]# uptime -s
2019-07-30 09:29:34

Checking System Uptime using w Command


You can also use another command called w to show how long the system has been running in your Linux systme. type:

$ w

Outputs:

[[email protected] ~]# w
07:19:39 up 73 days, 21:50, 1 user, load average: 0.15, 0.08, 0.06
USER TTY FROM [email protected] IDLE JCPU PCPU WHAT
root pts/0 111.198.226.116 07:16 3.00s 0.01s 0.00s w

You would see that the system is running from 73 days, 21 hours and 50 minutes.

Checking System uptime using Top Command


you can also use top command to display system uptime in your Linux system, type:

$ top

Outputs:

[[email protected] ~]# top
top - 07:19:44 up 73 days, 21:50, 1 user, load average: 0.13, 0.08, 0.06
Tasks: 96 total, 2 running, 94 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.5 us, 4.0 sy, 0.0 ni, 95.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1014888 total, 82592 free, 343536 used, 588760 buff/cache
KiB Swap: 4194300 total, 4056644 free, 137656 used. 349176 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
30 root 20 0 0 0 0 S 2.0 0.0 1:04.86 kswapd0
3 root 20 0 0 0 0 S 0.5 0.0 2:04.49 ksoftirqd/0
340 root 20 0 37236 1184 1056 S 0.5 0.1 31:24.97 systemd-jou+

Checking Last Reboot Time in Linux


You can also use the last reboot command to show a log of all the reboots since the log file was created. and The pseudo user reboot logs in each time the system is rebooted. type:

$ last reboot

Outputs:

[[email protected] ~]$ last reboot
reboot system boot 4.18.0-80.7.1.el Sat Oct 12 02:32 still running
reboot system boot 4.18.0-80.7.1.el Fri Oct 11 01:20 - 06:09 (04:48)
reboot system boot 4.18.0-80.7.1.el Wed Oct 9 01:09 - 02:51 (01:41)
reboot system boot 4.18.0-80.7.1.el Tue Oct 8 02:53 - 11:41 (08:47)
reboot system boot 4.18.0-80.7.1.el Sun Oct 6 07:03 - 13:18 (06:14)
reboot system boot 4.18.0-80.el8.x8 Sun Oct 6 04:49 - 13:18 (08:29)
reboot system boot 4.18.0-80.el8.x8 Fri Oct 4 04:12 - 13:03 (08:50)
reboot system boot 4.18.0-80.el8.x8 Wed Oct 2 07:07 - 12:17 (05:09)
reboot system boot 4.18.0-80.el8.x8 Wed Oct 2 05:13 - 07:07 (01:53)
reboot system boot 4.18.0-80.el8.x8 Wed Oct 2 05:04 - 07:07 (02:03)
reboot system boot 4.18.0-80.el8.x8 Wed Oct 2 04:23 - 07:07 (02:43)
reboot system boot 4.18.0-80.el8.x8 Tue Oct 1 11:54 - 20:35 (1+08:40)
reboot system boot 4.18.0-80.el8.x8 Sun Sep 29 22:43 - 11:01 (12:18)
reboot system boot 4.18.0-80.el8.x8 Sat Sep 28 21:51 - 11:46 (13:55)
reboot system boot 4.18.0-80.el8.x8 Wed Sep 25 22:30 - 22:33 (00:03)
reboot system boot 4.18.0-80.el8.x8 Tue Sep 24 23:17 - 09:09 (09:51)

wtmp begins Tue Sep 24 23:17:38 2019

Conclusion


You should know that how to find the system uptime using uptime/w/top commands in your CentOS/RHEL/Ubuntu Linux.

You might also like:

Sidebar



back to top