How to create a Java Thread dump

To create a java thread dump in Linux you must send a QUIT signal to your java process. JVM then catches that and prints the thread dump to standard output. If you are running your program from a script that has it's output directed to a file the thread dump will be written to that file obviously .

So first do we need to find the PID of our java program.

ps -ef | grep java

for example this could return :

lapps     3243  3065 21 Nov12 ?        08:01:50 java -Xms2048m -Xmx10g -XX:MaxPermSize=256m -Djava.awt.headless=true -XX:+UseParallelGC -XX:-UseGCOverheadLimit -classpath .:./test.jar:./lib/:./lib/* mypackage.org.TestApp

Now that we have 3243 as the PID, we simply send a QUIT signal to it.

kill -QUIT 3243

1 comment: