美文网首页
定时清理缓存

定时清理缓存

作者: Nick_4438 | 来源:发表于2018-08-05 22:59 被阅读0次

前言

本文介绍如何在centos 中清理RAM Memory Cache, Buffer and Swap Space

清理脚本

clearcache.sh

#!/bin/bash
# Note, we are using "echo 3", but it is not recommended in production instead use "echo 1"
su -c "echo 3 >'/proc/sys/vm/drop_caches' && swapoff -a && swapon -a && printf '\n%s\n' 'Ram-cache and Swap Cleared'" root

设置定时任务

crontab -e
0 4 * * * root /{path of file}/clearcache.sh

参数

  1. Clear PageCache only.
sync; echo 1 > /proc/sys/vm/drop_caches
  1. Clear dentries and inodes.
sync; echo 2 > /proc/sys/vm/drop_caches
  1. Clear PageCache, dentries and inodes.
sync; echo 3 > /proc/sys/vm/drop_caches 

参考文献

http://man.linuxde.net/sync
https://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux/

相关文章

  • 定时清理缓存

    前言 本文介绍如何在centos 中清理RAM Memory Cache, Buffer and Swap Spa...

  • crontab定时任务

    使用crontab配合shell脚本定时清理缓存 Linux服务器用一段时间就会出现buff/cache内存占用过...

  • Xcode清空缓存及Xcode报错记录

    Xcode清空缓存 iOS开发长时间使用Xcode会产生一系列的缓存,定时清理可以节省出一大部分内存。 移除iPh...

  • 12|第十二课:禁用清理二级缓存

    一、历史回顾 (一)、二级缓存使用 二、禁用清理二级缓存和整合Ehcache缓存 (一)、禁用清理二级缓存 清理:...

  • iOS开发-一句代码调用实现清理缓存功能

    iOS开发-清理缓存,将计算缓存,清理缓存封装成类方法,并将清理结果利用block方法实现返回,一键调用,轻松实现...

  • SDWebImage清除缓存

    //清理缓存 [[SDImageCache sharedImageCache] clearDisk];//清理磁盘...

  • 定时清理

    我们的一生会经历很多很多的东西,全部都背着那会特别特别累。所以,定时清理回忆,定时清理不再需要的、或者很舍不得却在...

  • 定时清理

    日常生活中,定时清理,是更好的开始。有时候,我们只关注了买东西的瞬间,但却不注意定时清理。像不用的东西过了期,占用...

  • uniapp缓存计算、缓存清理

    计算缓存大小方法 清理缓存方法

  • 开发中的一些经验(缓存)

    清理app缓存

网友评论

      本文标题:定时清理缓存

      本文链接:https://www.haomeiwen.com/subject/rklvpftx.html