7

How can I look at several processes at once, instead of just one?

For example… typing in bash, shows bash processes.. how to I show both bash and say httpd?

First thoughts.. bash|httpd, no. Or bash httpd, no. Long story short, nothing i tried worked. Is it possible?

enter image description here

2
  • 2
    What are you ultimately trying to achieve? Command-line tools top and ps list running processes. Depending on what you're trying to do, perhaps running one of those commands and filtering the output with grep would be a better solution.
    – bneely
    Feb 4, 2012 at 14:57
  • its just nice to keep an eye on "some processes" rather than "just one" or "all of them".... but as is often the case, apple almost deliberately seems to disable access to any sort of usable sorting or filtering syntax - although it's all there, underneath the skin.. instead strong-arming "simplicity" - over clever, and unobtrusive implementations that would let people who need "more meta" - have it.
    – alex gray
    Feb 4, 2012 at 17:01

3 Answers 3

2

This doesn't seem to be possible with Activity Monitor. Unfortunately top doesn't accept several pids to monitor either, so you have to revert to a half-manual (and rather unelegant) solution using Terminal:

while :; do
    clear
    top -l 1 -pid PID-TO-MONITOR | tail -1
    top -l 1 -pid ANOTHER-PID-TO-MONITOR | tail -1
    sleep 5
done

Given some basic bash skills you can wrap this into a shell script if needed often.

Or open several terminal windows and run top on specific processes in each of them. Might be kind of heavy on your CPU though...

1
  • thanks for the answer, although the result is pretty icky... 22057 mdworker 0.0 08:01.26 6 3 67+ 267+ 24M+ 46M+ 37M+ 100M+ 2512M+ 22057 477 stuck 501 4711582+ 563+ 2541479+ 698439+ 9115613+ 4938769+ 1364892+ 35330+ 18K+ 95M+ localadmin etc.. but it refreshes like a madman.. limiting the usefullness. oh well, accepted until something dreamier comes along :-).
    – alex gray
    Sep 18, 2012 at 9:21
5

Not sure when this feature was added (the original question is 8 years old at the time of this writing) BUT, this is possible now. Just hold ⇧SHIFT or ⌘COMMAND to select multiple processes in the Activity Monitor window, and then go to the View menu and choose Selected Processes:

in Big Sur 11.0.1 it looks like this
activity monitor selected processes

example, filtering only airportd, authd and bird activity mon filtered

2
  • Does this "filter" those terms and display any/all new processes that match that term? Or display only the exact set of processes that you select?
    – pkamb
    Sep 16, 2021 at 17:32
  • Thanks! Great hint for a great feature! Really amazing that this comes from a stock macOS utility now. Was almost sure I had to resort to 3rd party or custom shell script involving top.
    – porg
    Nov 11, 2021 at 17:31
1

To supplement @Patrix command line suggestion: use grep to match multiple PIDs by name. For example:

top -s 2 -l 5 | grep -w 'bash\|httpd'

Samples processes matching either bash or httpd every 2 seconds over 5 queries (10 seconds total to run).

More generally:

top -s [interval time in seconds] -l [# of intervals] | grep -w 'process1\|process2\|process3'

You must log in to answer this question.

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