vim tomcat_mem.sh
NAME=$1
#部署项目名称
#PID=`ps -ef|grep tomcat|grep $NAME|awk '{print $2}'`
PID=`ps -ef|grep $NAME|grep -v "grep $NAME"|awk '{print $2}'`
MEM=`top -p $PID -n 1 |grep $PID |awk '{print $6}'|awk -F"m" '{print $1}'`
echo $MEM
执行脚本:
tomcat_mam.sh www