What's the easiest way to show memory usage of processes with the same name?
Not individually, but the total usage.
To figure out how much things like Chrome consume memory.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityWhat's the easiest way to show memory usage of processes with the same name?
Not individually, but the total usage.
To figure out how much things like Chrome consume memory.
I would select all the process with pgrep
, print resident memory with ps
and sum it using awk
:
ps -p $(pgrep -d, -x chrome) -ho rss | awk '{s+=$1} END {printf "%i", s}'
For some process it's probably better to look for full command line instead of name. On my distribution, using chromium:
ps -p $(pgrep -d, --full /usr/lib/chromium/chromium) -ho rss | awk '{s+=$1} END {printf "%i", s}'
error: only one heading option may be specified
(from ps). I'm on Gentoo
– Hrisip
Feb 20 at 18:06
ps -p $(pgrep -d, -x chrome) --no-headers -o rss | awk '{s+=$1} END {printf "%i", s}'
same.
– Hrisip
Feb 20 at 19:41
ps -p $(pgrep -d, -x chrome) -o rss | awk '$1 ~ /^[0-9]+$/ {s+=$1} END {printf "%i", s}'
?
– kaliko
Feb 20 at 19:51
pgrep
command gives output in the following form 3402 chrome,3410 chrome
– Hrisip
Feb 20 at 19:55