while true ; do if [ $(($(ps aux | grep '/usr/local/tomcat7' | grep -v grep | awk '{print $6}') / 1048576)) -ge 4 ] ; then /usr/local/tomcat7/bin/shutdown.sh && sleep 1 && kill -9 $(ps -ef | grep '/usr/local/tomcat7' | grep -v grep | awk '{print $2}') && sleep 1 && /usr/local/tomcat7/bin/startup.sh ; fi ; sleep 60 ; done