当前位置: 编程技术>java/j2ee
输出java进程的jstack信息示例分享 通过线程堆栈信息分析java线程
来源: 互联网 发布时间:2014-11-01
本文导语: 代码如下:#!/bin/shpro_name=java #process namekeys=`ps -ef |grep "$pro_name" |grep -v "grep" | awk '{print $2}'`nowdate=`date +%Y%m%d%H%M%S` jstackpath="/usr/java/jdk1.6.0_07/bin/jstack"cpulogpath="/home/" for key in ${keys}do cpulogpath_file="${cpulogpath}cpu_${nowdate}${key}.log" cpusta...
代码如下:
#!/bin/sh
pro_name=java #process name
keys=`ps -ef |grep "$pro_name" |grep -v "grep" | awk '{print $2}'`
nowdate=`date +%Y%m%d%H%M%S`
jstackpath="/usr/java/jdk1.6.0_07/bin/jstack"
cpulogpath="/home/"
for key in ${keys}
do
cpulogpath_file="${cpulogpath}cpu_${nowdate}${key}.log"
cpustackCmd="${jstackpath} -l ${key} >${cpulogpath_file}"
echo "command: ${cpustackCmd}"
eval $cpustackCmd
done