I read that I can find the process ID and then use kill command to save the thread dump to a file. But the following example does not return anything...

# ps aux | grep -i java
wcuser    9136  0.0 17.2 3416012 1412772 ?     Sl   Oct10   2:32 /usr/bin/java -Djava.util.logging.config.file=/home/../conf/logging.properties ..... ...... start

# kill -3 9136

What is thread dump?

How exacty does it work?

Is it possible to automate the process to take the dump to a file periodically?

1 Answer 1


It sends it to where stdout is pointed to for this process. An easier way is to use jstack, which is provided by the JDK. With this tool, you can simply do:

jstack <pid> > thread-dump.out

Make sure you do this as the user the process is running as.

What a thread dump is, is a snapshot representation of where all current threads within that Java process are busy on the stack. There are tools which let you analyze raw thread dumps more easily, such as VisualVM or TDA.

It is of course possible to do this periodically, just put a statement like that in a cronjob.

  • Is there any way to find the Java process ID other than # ps aux | grep -i java
    – shantanuo
    Oct 12, 2011 at 8:28
  • Sure, $(pidof java) or using the jps tool will let you do the same. Oct 12, 2011 at 8:33
  • or pgrep java.
    – quanta
    Oct 12, 2011 at 10:42

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.