Linux uptime command (uptime) [Basic Guide]

The Linux Uptime Command shows how long the system has been on the air, the number of users logged in, and the CPU load.

The most common options are:

  • -p Show when the system has been connected in a “cute” way
  • -s Shows since when the system has been connected in the format YEAR—MONTH—DAY HOUR:MINUTE:SECOND

The CPU load averages shown by the uptime command are calculated with an average of the processes running or waiting for the CPU. These averages are not normalized by the number of CPUs.

It’s very important to remember that uptime shows the average CPU load in the last 1 minute, the last 5 minutes, and the last 15 minutes, in that order.

If the CPU load is greater than 1, and if the system has only one CPU, it means that the CPU usage is beyond capacity, so there is a long wait per CPU for processes.

But to draw more accurate conclusions, it will depend on the time when the average CPU is above 1. If there was a peak in CPU usage at the last minute, but the average load at times of 5 and 15 minutes are low, it is not an indication that there is a need to change the CPU. But if the averages are high at 5 and 15 minutes too, it means that the processing capacity may be poorly planned in relation to the system load.

It is also important to know that these averages are not normalized by the number of processors. A load number of 1 on a 4-processor system means that the CPUs are idle 75% of the time. Thus, it can be understood that to overload a system with 4 CPUs, the average load must be greater than 4.

In this example, see that there are plenty of CPUs:

$ uptime 20:35:37 up 31 days, 9:41, 1 user, load average: 0.02, 0.02, 0.00

The -p option shows when the system has been connected in the day count style since:

$ uptime -p up 4 weeks, 3 days, 9 hours, 45 minutes

And the -s option shows how long the system has been connected in the date format:

$ uptime -s 2019-08-15 10:53:45

The number of CPUs in a system can be viewed in the /proc/cpuinfo file, with the “model name” parameter:

$ grep -c 'model name' /proc/cpuinfo 1

Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.

Did you like it?

Share

Uirá Endy Ribeiro

Uirá Endy Ribeiro is a Software Developer and Cloud Computing Architect with a 23-year career. He has master's degrees in computer science and fifteen IT certifications and is the author of 11 books recognized in the IT world market. He is also Director at Universidade Salgado de Oliveira and Director of the Linux Professional Institute - LPI Director's Board.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Need help?