Sample jstack information for output Java processes is Shared by analyzing Java threads through thread stack information

  • 2020-04-01 02:47:14
  • OfStack


#!/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


Related articles: