Get the PID of Java
jstack -F <your-pid> >dump.log
sudo jstack -F `pidof java` > /tmp/`hostname`_threaddump_`date +”%Y%m%d_%H%M”`.txt
- ps -el | grep java
- top | grep java
:~$ jstack -F 31987 > dump_22_09_2015_3.log
Attaching to process ID 31987, please wait…
Debugger attached successfully.
Server compiler detected.
JVM version is 24.76-b04
Sometimes following error might occur:
Unable to open socket file: target process not responding or HotSpot VM not loaded The -F option can be used when the target process is not responding
- jstck must be run as the same user as the java process which in my case is Jetty.
- sudo -u jetty jstack <your-pid> > dump.log