I'd like to know how much resource a specific command is using.
top
and htop
displays information on per process basis but I'd like the information to be shown on per command basis. E.g. I'd like to know how much RAM chrome is using.
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 communityPressing H
in htop
group the processes by the main thread (command), actually it toggles the threads visibility.
F6
works to show only the process group, but sorting disables tree view.
Oct 22, 2019 at 0:17
htop
will not show totals no matter what you do.
Oct 23, 2019 at 0:02
This is possible in atop
. Just press p
when running it. From the help:
Accumulated figures:
'u' - total resource consumption per user
'p' - total resource consumption per program (i.e. same process name)
'j' - total resource consumption per container
atop
version will be released with no cron
dependency.
Oct 31, 2019 at 4:27
firefox
launches many Web Content
processes (superuser.com/questions/1299746/…), and these would show separately. There is no a priori way to tell which to sum.
Sep 16, 2021 at 11:02
You could run top
in batch mode -b
with 1 iteration -n1
. You grep it, pipe it to awk
, SUM
the result and print it.
top -b -n1 | grep chrome | awk '{ SUM += $9} END { print SUM }'
I don't know which column you want to output. Change $9
to fit your needs.
firefox
launches many Web Content
processes, that would not enter the sum (superuser.com/questions/1299746/…). ps -eo <several column identifiers>,command
instead of top -b -n1
could fix this problem. See this.
Sep 16, 2021 at 13:54
top
andps
vary by OS. You should tag the question with the OS you are using.