Categories: How-To

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.

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.

Share
Published by
Uirá Endy Ribeiro

Recent Posts

Sudo command on Linux (privilege scale) [Basic Guide]

The sudo command on Linux executes a given command as if it were another user.…

2 years ago

SS command on Linux (investigate the network) [Basic Guide]

The ss command on Linux is extremely useful for investigating sockets, providing various information about…

2 years ago

Free Linux command (memory usage) [Basic Guide]

Free Linux command shows the amount of total memory in use and available, as well…

2 years ago

Linux while command (loop – while) [Basic Guide]

The shell has structures for testing conditions and executing certain program sequences several times (loop),…

2 years ago

Linux fstab file (disk mount setup) [Basic Guide]

The /etc/fstab file stores the configuration of which devices should be mounted and what is…

2 years ago

Netcat command on Linux (Swiss network knife) [Basic Guide]

The Netcat Command in Linux or nc is a utility used to do “almost anything”…

2 years ago

This website uses cookies.