Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm run top and I want to always see java/tomcat/redis/mysql/mongo, is that possible?

share|improve this question

You could to something like this

top -p `pgrep -d ',' "java|tomcat|redis|mysql|mongo"`

This gets pgrep to produce a comma separated list of pid's that are passed to top -p

share|improve this answer
Much simpler :) – Mircea Vutcovici Dec 23 '11 at 23:04
I was struggling to figure out how to find the process list for multiple process names till I saw how you did it. – Iain Dec 23 '11 at 23:08

Try this:

alias mytop='echo $(sed "s/\([0-9]*\)/-p \1/g;s/^/top /" <(pgrep -d" " "java|redis|mysql|mongo"))'
share|improve this answer

Not quite what you're looking for, but sometimes a process is run by it's own user, like apache2 is often run by user www-data.

You can use that to limit top's output to only the processes by that user, effectively only showing apache2 processes by using this command:

top -u www-data
share|improve this answer
Great! I was wondering how to list user specific processes – razor7 Mar 24 at 18:38

Check man top manual page for more details about top utility...

Semms you need -p parameter

-p : Monitor PIDs as: -pN1 -pN2 ... or -pN1, N2 [,...]

        Monitor only processes with specified process  IDs.   This  option
        can  be given up to 20 times, or you can provide a comma delimited
        list  with  up  to  20  pids.   Co-mingling  both  approaches   is
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.