crontab设置
*/20 * * * * /root/shell_.sh
shell_.sh内容
第一次运行建议取消脚本注释手动执行一次查看结果
#!/bin/bash
#当可用内存少于300M的时候释放内存。
do_free_mem=300
mem_now=`free -h |grep Mem |awk -F ' ' '{print $4}'`
mem_type=${mem_now: -1}
mem_num=${mem_now%?}
#echo ${mem_type}
#echo ${mem_num}
if [ "${mem_type}" == "M" ];then
#echo ${mem_num} ${do_free_mem}
if (( ${mem_num} < ${do_free_mem} ));then
#free -h
#if [ $? == 1 ]
#then
#yum update procps -y
#echo "释放前"
#free -h
#fi
echo 3 > /proc/sys/vm/drop_caches
#free -h
fi
fi
© 著作权归作者所有
文章评论(0)