- 查看内存以及缓存状态
free -g
- 创建清除缓存的脚本
vim /home/script/clear_buff_cache.sh
#!/bin/bash
#开始清理缓存
echo "开始清除缓存"
#写入硬盘,防止数据丢失
sync;sync;sync
#延迟10秒
sleep 10
#清理缓存
echo 3 > /proc/sys/vm/drop_caches
3.设置定时任务
crontab -e
#下面为新增的内容
# clear buff/cache
#每天凌晨0:10执行XX脚本
10 0 * * * /home/script/clear_buff_cache.sh
4.重新启动定时任务
service crond restart
参考:
https://www.jianshu.com/p/016f7cf0380d
设置定时调度时间参考:
https://www.jb51.net/article/139368.htm