Created
October 29, 2020 09:28
-
-
Save saswata-dutta/7ecf357f8df217b5ccbff6747f192be2 to your computer and use it in GitHub Desktop.
Periodically creates thread dump of a running java process to debug unresponsive/blocked threads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# get process_id using jps -v or ps | |
# ps -mo pid.lwp.stime.time.cpu -C java | |
# your/path/to/jstack `ps aux | grep java | grep -v grep | awk '{print $2}'` >> threaddump.log | |
readonly process_id=${1} | |
readonly times=${2:-10} | |
readonly pause=${3:-10} | |
for((i=1;i<=$times;i++)) | |
do | |
dump="threaddump_${i}" | |
jstack ${process_id} > ${dump} | |
echo "dumped to ${dump}" | |
sleep ${pause} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment