0

It is not the solution but if a patch while we investigate because our Tomcat is filling memory.

Below the solution

I had a problem with tomcat memory filled me with my website and I was falling. So I created this script so that when physical memory is automatically reset to 95

  • 1
    please describe the question this answers and post the script as an answer. As it is now, it seems that you still look for answers. – amotzg Nov 25 '14 at 07:40
  • Ok thank you amotzg!!!! This is a solution –  Nov 25 '14 at 07:55
  • possible duplicate of [Detecting out of memory errors](http://stackoverflow.com/questions/11508310/detecting-out-of-memory-errors) – mindas Nov 25 '14 at 10:48
  • @mindas : Mindas: This is not a duplicate. is a quick fix while we try to fix the tomcat. I have a very large web application and has several bugs (because he has touched many people and has many patches). Instead of looking I put this script and I can sleep peacefully. I have extended memory but I have a loop that makes me fill my 11GB of physical memory tomcat with time –  Nov 25 '14 at 12:17

1 Answers1

1

Solution:


porcentaje=95

usoMemoria=$(ps aux | grep tomcat | grep -v grep | awk '{printf ("%.0f", $4)}')

if [ $usoMemoria -ge $porcentaje ]; then

    echo "Se ha superado el tope (95%) de memoria que se ha establecido para el Tomcat. Se     procede a su reinicio automatico"

    echo "$(date)"

    echo "Comenzando..."

    service tomcat7 restart

    echo "Terminando Script..."
fi
exit 0

By: http://www.cst.16mb.com