Blankman Asked: 2011-12-24 14:19:00 +0800 CST2011-12-24 14:19:00 +0800 CST 2011-12-24 14:19:00 +0800 CST Is it possible to filter top to show specific processes? 772 I'm run top and I want to always see java/tomcat/redis/mysql/mongo, is that possible? ubuntu performance-monitoring top 4 Answers Voted Iain 2011-12-24T14:59:44+08:002011-12-24T14:59:44+08:00 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 DanMan 2013-07-26T00:40:08+08:002013-07-26T00:40:08+08:00 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 Sergey 2011-12-24T14:35:39+08:002011-12-24T14:35:39+08:00 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 permitted. Mircea Vutcovici 2011-12-24T14:48:42+08:002011-12-24T14:48:42+08:00 Try this: alias mytop='echo $(sed "s/\([0-9]*\)/-p \1/g;s/^/top /" <(pgrep -d" " "java|redis|mysql|mongo"))' mytop
You could to something like this
This gets
pgrep
to produce a comma separated list of pid's that are passed totop -p
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:
Check man top manual page for more details about top utility...
Semms you need -p parameter
Try this: