#!/bin/bash
used=`free -m | awk 'NR==2' | awk '{print $3}'`
free=`free -m | awk 'NR==2' | awk '{print $4}'`
echo "===========================" >> /opt/dropcache/logs.txt
date >> /opt/dropcache/logs.txt
echo "Memory usage | [Use:${used}MB][Free:${free}MB]" >> /opt/dropcache/logs.txt
# drop caches when the free memory less than 10G
if [ $free -le 10000 ] ; then
sync && echo 1 > /proc/sys/vm/drop_caches
sync && echo 2 > /proc/sys/vm/drop_caches
sync && echo 3 > /proc/sys/vm/drop_caches
echo "OK" >> /opt/dropcache/logs.txt
else
echo "Not required" >> /opt/dropcache/logs.txt
fi
used=`free -m | awk 'NR==2' | awk '{print $3}'`
free=`free -m | awk 'NR==2' | awk '{print $4}'`
echo "===========================" >> /opt/dropcache/logs.txt
date >> /opt/dropcache/logs.txt
echo "Memory usage | [Use:${used}MB][Free:${free}MB]" >> /opt/dropcache/logs.txt
# drop caches when the free memory less than 10G
if [ $free -le 10000 ] ; then
sync && echo 1 > /proc/sys/vm/drop_caches
sync && echo 2 > /proc/sys/vm/drop_caches
sync && echo 3 > /proc/sys/vm/drop_caches
echo "OK" >> /opt/dropcache/logs.txt
else
echo "Not required" >> /opt/dropcache/logs.txt
fi
浙公网安备 33010602011771号