当前位置: > Linux服务器 > Tomcat >

Linux下查看tomcat内存状况并执行重启命令

时间:2014-10-07 17:27来源:linux.it.net.cn 作者:it
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
export JAVA_HOME=/usr/java/jdk1.6.0_13
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$PATH:$JAVA_HOME/bin
export LANG=en_US.UTF-8
ram_max=25
pid_ram=`ps -ef | grep java| grep -v "grep"|awk '{print $2}'|xargs|awk '{print $1}'`
ram=`ps -e -o 'user,pid,%cpu,%mem,vsz,rss,tty,stat,start,time,command' |grep java|grep -v grep |awk '{print $4}'|xargs|awk '{print $1}'`
#echo $pid_ram
#echo $ram
#echo $ram_max
if(echo $ram $ram_max | awk '!($1>$2){exit 1}')
then
#echo 1
kill -9 $pid_ram
sleep 2
cd /usr/java/tomcat5.5/bin
\./startup.sh
fi
 
(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容