본문 바로가기

스크립트

[스크립트] thread dump && heap dump

반응형

thread dump && heap dump

vim TH_dump.sh
#!/bin/bash
 
PID=`ps -ef | grep java | awk '{print $2}'`
 
#####thread dump
#ps -ef | grep java| awk '{print $2}' | xargs kill -3
 
echo "Starting Thread Dump..."
        for(( i=0; i<3; i++)) ;
        do
        cp /app/tomcat/catalina/logs/`date +%Y%m%d`.log /app/tomcat/catalina/logs/threaddump_`date +%Y%m%d_%H%M%S`.log
        echo "$ i  threaddump is successed"
        sleep 3
done
 
#####java heap dump
echo "Starting Heap Dump..."
/usr/bin/jmap -dump:file=/root/heap_`date +%Y%m%d_%H%M%S`.dump $PID
chmod +x TH_dump.sh

 

 

728x90
반응형