Linux Command :: uptime
Bhaskar S | 02/01/2013 |
The Linux uptime command is a handy utility that allows one to get the following useful information about a system:
Current time
How long the system has been up
How many users are logged into the system
Current system load averages for 1 minute, 5 minutes and 15 minutes
Let us go ahead and execute the uptime as follows:
$ uptime
The following is the output:
20:40:07 up 13:55, 2 users, load average: 0.46, 0.28, 0.27
The value 20:40:07 indicates the current system time.
The value 13:55 indicates how long the system has been up for. In our case its been up for 13 hours and 55 minutes.
The value 2 users indicates there are 2 users logged into the system currently.
The set of 3 values 0.46, 0.28, 0.27 after the words "load average:" indicates the current system load averages for the past - 1 minute, 5 minutes and 15 minutes. In other words, the system load average for the past 1 minute is 0.46, the system load average for the past 5 minutes is 0.28, and the system load average for the past 15 minutes is 0.27.
What does system "load average" mean ? To explain that, lets look at a practical real-world example.
Have you been to a theme park to get on a popular roller coaster ? There are about 4 or more gates through which you get in to occupy a vacant seat in the roller coaster cars. Once all the seats in the roller coaster cars are filled, the gates are closed and the roller coaster cars zoom past for the ride. People wait in the queue outside the closed gates for their turn for the duration of the current ride. Sounds familiar ?
Think of the roller coaster cars as the cores in the CPU. When a person rides the coaster for a set duration, it is analogous to an active process executing on a CPU core of the system. More CPU cores means more processes are active at one time. People waiting in the queue for their turn is similar to processes that are scheduled to be run and waiting for a free CPU core.
So, what is load average ? It is the average number of people currently riding the roller coaster plus the number of people waiting in the queue to get on the roller coaster for a given time period, say 1 minute or 5 minutes. In other words, the load of the system then is the average number of processes waiting in the queue to be executed plus the number of processes already actively executing.
For an optimally running system, the load averages should be less than or equal to the number of CPU cores in the system. So for a 8-core system, the load averages should be less than or equal to 8 to indicate the system is running efficiently.