1
1
Fork 0
scripts/restart_apache_at_ram_thres...

28 lines
632 B
Bash
Executable File

#!/bin/bash
i=1
j=1
threshold=850
while [ 2 -gt 1 ]; do
echo "run count: $i"
sleep 30
mem=$(free -m | grep + | awk '{print $3}')
echo " used memory: $mem"
echo " threshold: $threshold"
if [ $mem -gt $threshold ]; then
echo " memory usage too high"
echo " too high mem count: $j (apache will be restarted if count reaches 10)"
let j++
if [ $j -gt 10 ]; then
echo " resetting apache to clear memory"
/etc/init.d/apache2 restart
j=1
fi
else
echo " memory below threshold"
fi
let i++
done
exit 0