linux 释放缓存脚本,Linux 设置定时清除buff/cache的脚本

查看内存缓存状态

[root@heyong ~]# free -m

total used free shared buff/cache available

Mem: 96406 19256 11311 66 65837 76421

Swap: 4095 1016 3079

清理缓存的脚本

[root@heyong ~]# vim /home/script

#!/bin/bash

#开始清理缓存

echo "开始清除缓存"

#写入硬盘,防止数据丢失

sync;sync;sync

#延迟10秒

sleep 10

#清理缓存

echo 3 > /proc/sys/vm/drop_caches

设置定时任务(每天凌晨2:30清理一次)

[root@gonghuikeji ~]# crontab -e

clear buff/cache

30 2 * /home/script/clear_buff_cache.sh

标签:缓存,cache,sync,清理,Linux,root,buff

来源: https://blog.51cto.com/heyong/2426817