#!/bin/env bash
##this is memmorycontrol Script
##author xw 2018.3.16
mem_used=`free -m |grep '^Mem' |awk '{print $3}'`
mem_total=`free -m |grep '^Mem' |awk '{print $2}'`
mem_percent=$((mem_used * 100 / mem_total))
war_file=/var/log/memmorycontrol.log
if (($mem_percent > 40 ));then
echo "`date +%F-%M` memory: ${mem_percent}%" |tee $war_file
fi
if [ -f $war_file ];then
mail -s "memmoryallowance" wang.cong@aliyun.com < $war_file
fi
***计划任务**