Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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