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/clear_buff_cache.sh
#!/bin/bash

#开始清理缓存
echo "开始清除缓存"

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

#延迟10秒
sleep 10

#清理缓存
echo 3 > /proc/sys/vm/drop_caches

  

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

[root@heyong ~]# crontab -e

# clear buff/cache

30 2 * * * /home/script/clear_buff_cache.sh

  

 

相关文章:

  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2021-06-11
  • 2021-06-28
  • 2021-08-18
猜你喜欢
  • 2022-01-28
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
相关资源
相似解决方案