#!/bin/bash echo $(date "+%Y-%m-%d %H:%M:%S") [timing fullgc] start >> timing-fullgc.log java_pid=$(jps | grep 'StartApp'| awk '{print $1}') if [ -n "$java_pid" ] then echo $(date "+%Y-%m-%d %H:%M:%S") get java_pid $java_pid >> timing-fullgc.log jmap -histo:live $java_pid > /dev/null 2>> timing-fullgc.error if [ $? -eq 0 ];then echo $(date "+%Y-%m-%d %H:%M:%S") $java_pid timing fullgc success else echo $(date "+%Y-%m-%d %H:%M:%S") $java_pid timing fullgc error fi else echo $(date "+%Y-%m-%d %H:%M:%S") get java_pid fail >> timing-fullgc.log fi echo $(date "+%Y-%m-%d %H:%M:%S") [timing fullgc] end >> timing-fullgc.log