≡ Menu

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

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.
Share this on:
{ 9 comments… add one }
  • Stefan August 29, 2007, 2:18 pm

    This information is wrong. The correct command would be:

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

    The above does not work on Solaris 8.

    • Brad August 7, 2013, 6:18 pm

      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}’


  • Oo.et.oO September 27, 2007, 7:52 pm

    stefan. his example clearly shows that that just doesn’t work all the time. specifically when uptime is

  • Szy May 13, 2008, 1:19 pm

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

    • Paresh September 17, 2012, 5:04 am

      Yes, U r right Szy, it works and there should not be ‘s’ in average… It worked fine on AIX. thanks

  • Chandra December 23, 2008, 10:30 am

    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)

  • Yang Yang April 14, 2009, 4:45 am

    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?

    • Paresh September 17, 2012, 5:11 am

      It means, load averages of CPU in last 1, 5 and 15 mins…

  • fernandeznico July 5, 2016, 3:26 pm

    Can use “getloadavg” function of “stdlib.h”.

    (FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=getloadavg)

Security: Are you a robot or human?

Leave a Comment

   Tagged with: , , , ,