1

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?

quanta
  • 50,327
  • 19
  • 152
  • 213
shantanuo
  • 3,459
  • 8
  • 47
  • 64

1 Answers1

4

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.

objectified
  • 434
  • 2
  • 3