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.

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

10 comments… add one
  • Stefan Aug 29, 2007 @ 14:18

    This information is wrong. The correct command would be:

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

    The above does not work on Solaris 8.

    • Brad Aug 7, 2013 @ 18:18

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


  • Sep 27, 2007 @ 19:52

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

  • Szy May 13, 2008 @ 13:19

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

    • Paresh Sep 17, 2012 @ 5:04

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

  • Chandra Dec 23, 2008 @ 10:30

    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 Apr 14, 2009 @ 4:45

    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 Sep 17, 2012 @ 5:11

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

  • fernandeznico Jul 5, 2016 @ 15:26

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


  • Eppy Jul 31, 2020 @ 8:12

    cat /proc/loadavg

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.