1

In FreeBSD, how to find the current memory usage (wired, inactive, cache, etc) in a shell script?

This must be for a regular /bin/sh script, not bash, zsh, etc...

1
  • 1
    Have you checked ps and top? I think both are available on BSD. Not sure about free, does that exist on BSDs?
    – terdon
    Commented Mar 24, 2015 at 22:53

1 Answer 1

2

I think you need it :

root@firewall:/usr/ports/misc/gnu-watch # uname -a

FreeBSD firewall 10.1-STABLE FreeBSD 10.1-STABLE #0 r279885: Thu Mar 12 01:04:57 CET 2015     root@firewall:/usr/obj/usr/src/sys/PF  i386
root@firewall:/usr/ports/misc/gnu-watch # vmstat 
 procs      memory      page                    disks     faults         cpu
 r b w     avm    fre   flt  re  pi  po    fr  sr ad0 pa0   in   sy   cs us sy id
 1 0 0    304M   512M   229   1   1   0   244   5   0   0   47 1001  357  1  2 97
root@firewall:/usr/ports/misc/gnu-watch # 

vmstat has set of options for command line that you can use in your script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .