REINICIA APACHE EM SERVIDOR COM POUCA MEMORIA

#!/bin/bash
# REINICIA APACHE SE SERVIDOR ESTIVER COM POUCA MEMORIA

MEMORIA_MAXIMA_EM_USO=400

while sleep 10; do
  MEMORIA_EM_USO=$( free -m | awk '{print $3}' | head -n 2 | tail -n 1 )
  if [ $MEMORIA_EM_USO -gt $MEMORIA_MAXIMA_EM_USO ]; then
    echo "[ `date '+%d/%m/%Y %H:%M'` ] REINICIANDO APACHE, MEMORIA EM USO: $MEMORIA_EM_USO" | tee -a /var/log/$( basename $0 ).log
    apachectl restart &> /dev/null
  fi
done
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s