1

I want to see all the java processes & see the details of it in linux.

I'm using top command & it shows me all processes along with java.

But I would like to know if there is any way top command will show only java processes. I've many java programs running in my server & I want the top command to list only java processes so that I can see the details of them.

Is this possible? How can I do it in top command?

Thanks!

4

Install htop, press \, then enter java Enter.

2

Instead of top, use ps and if you want it to be refreshed periodically, use watch. For example:

watch -n 1 'ps aux | grep java'
2
top -p `pgrep -d, -f java`

Explanation:

 top -p pid[,pid,pid]

Provides top a list of pids to watch.

`pgrep -d, -f java`

Does a grep of the process names for 'java', and returns the comma seperated pid values.

1

If you have JDK ( unlikely on production servers) installed, there are set of tools that works with java process. jps/jmap etc

1
  • jps (as well as jstat,jstatd, and jconsole) is marked as experimental and unsupported in the Java 1.5 documentation. Same thing for jmap and its ilk (jinfo, jsadebugd, and jstack) - in the 1.5 documentation. The Java 7 documentation has identical warnings.
    – Mei
    Jan 11 '12 at 20:30
0

You need to filter output, so you can use 'grep' command, direct 'top' output using a pipeline '|'. So your command should look something like: top | grep java

If you just need to know info in one point of time you can use: ps aux | grep java

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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