Bash Shell: Find Out Linux / FreeBSD / UNIX System Load Average

last updated in Categories Linux, Monitoring, Sys admin, UNIX

Yes, I know we can use the uptime command to find out the system load average. The uptime command displays the current time, the length of time the system has been up, the number of users, and the load average of the system over the last 1, 5, and 15 minutes. However, if you try to use the uptime command in script, you know how difficult it is to get correct load average. As the time since the last, reboot moves from minutes, to hours, and an even day after system rebooted. Just type the uptime command:

$ uptime
Sample outputs:


1:09:01  up 29 min,  1 user,  load average: 0.00, 0.00, 0.00

$ uptime
Sample outputs:

2:13AM  up 34 days, 16:15, 36 users, load averages: 1.56, 1.89, 2.06

Traditionally, UNIX administrators used sed and other shell command in scripting to get correct value of load average. Here is my own modified hack to save the time
$ uptime | awk -F'load averages:' '{ print $2 }'
OR better use the following code:
$ uptime | awk -F'[a-z]:' '{ print $2}'
Output taken from my OS X desktop:

 1.24 1.34 1.35

Output taken from my Ubuntu Linux server:

 0.00, 0.01, 0.05

Output taken from my RHEL based server:

 0.24, 0.27, 0.21

Output taken from my FreeBSD based server:

 0.71, 0.71, 0.58

Please note that command works on all variant of UNIX operating systems.

See also

  • See chksysload.bash script to notify admin user if script load crossed certain limit and if so send them an email alert.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


10 comment

  1. This information is wrong. The correct command would be:

    uptime | awk '{print $10 " " $11 " " $12}'

    The above does not work on Solaris 8.

    1. This information is wrong.

      You can’t just pipe to awk and assume that the 10th field will be the load average.

      Because the time field could be 1 or 2 items. “47 days” or “15:45”. Because it’s not consistent you can’t assume the 10th field will be load average.

      # uptime
      18:17:27 up 47 days, 47 min, 2 users, load average: 0.09, 0.23, 0.42

      # uptime | awk ‘{print $10}’


  2. Actually it DOES work. I found that the ‘s’ in ‘averges’ should not be there. Otherwise it works like a charm!

  3. Actually This will work fine, cause there will be different output based on u r last reboot.

    # Find the correct field to extract based on how long
    # the system has been up, or since the last reboot.
    if $(uptime | grep day | grep min >/dev/null)
    elif $(uptime | grep day | grep hrs >/dev/null)
    elif $(uptime | grep day >/dev/null)
    elif $(uptime | grep min >/dev/null)

  4. Anybody care to explain what these load average figures mean? Is there a unit or is there anything scalely comparable to them? For example, I have:

    21:39:33 up 10:45, 5 users, load average: 9.86, 9.68, 10.64

    What do 9.86, 9.68 and 10.64 mean here?

Leave a Comment