#!/bin/bash
used=`free -m | awk ‘NR==2‘ | awk ‘{print $3}‘`
free=`free -m | awk ‘NR==2‘ | awk ‘{print $4}‘`
echo "==================================" >> /home/script/mem.log
date >> /home/script/mem.log
echo "Memory usage | [ Used:${used}MB ] [ Free:${free}MB ]" >> /home/script/mem.log
if [ $free -le 100 ];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
fi
原文地址:https://www.cnblogs.com/sunju/p/11154151.html
时间: 2024-10-16 10:33:44