linux 查看java最高cpu线程
#新建javacpu.sh ,并赋予可执行权限#!/bin/bashJAVA_PID=`top -b -n 1|grep java|head -n 1|awk '{print $1}'`HIGH_CPU_TID=`ps -mp $JAVA_PID -o THREAD,tid,time | sort -rn |head -n 3 |tail -n 1 |awk '{print $8}'`HIGH_C
·
#新建javacpu.sh ,并赋予可执行权限
#!/bin/bash
JAVA_PID=`top -b -n 1|grep java|head -n 1|awk '{print $1}'`
HIGH_CPU_TID=`ps -mp $JAVA_PID -o THREAD,tid,time | sort -rn |head -n 3 |tail -n 1 |awk '{print $8}'`
HIGH_CPU_TID_HEX=`printf "%x\n" $HIGH_CPU_TID`
echo "JAVA_PID: "$JAVA_PID""
echo "HIGH_CPU_TID: "$HIGH_CPU_TID""
echo "HIGH_CPU_TID_HEX: "$HIGH_CPU_TID_HEX""
echo `date` `(jstack $JAVA_PID | grep $HIGH_CPU_TID_HEX -A 30)`
echo `date` `(jstack $JAVA_PID | grep $HIGH_CPU_TID_HEX -A 30)` >> /usr/local/javacpu.log
#运行方法 ./javacpu.sh
更多推荐
已为社区贡献1条内容
所有评论(0)