输出所有java进程的gc状态

#!/bin/sh
#read -t 30 -p "请输入jstat命令监控间隔,次数:" time count
read -p "输入jstat命令监控间隔(1s输出一次,输入1000):" time
if [ -z "$time" ];then
        time=1000
    fi
read -p "输入jstat命令监控次数:" count
if [ -z "$count" ];then
        count=10
    fi

for javaid in `ps -ef|grep java|grep 'Xms' |awk '{print $2}'`
do
        echo  当前java pid=$javaid
        echo  当前应用 `ps -ef|grep "$javaid"`
        jstat -gcutil "$javaid" $time $count

done

 

posted @ 2019-12-11 15:57  Agoly  阅读(441)  评论(0编辑  收藏