pengpengboshi

自动清除内存缓存

自动清除内存缓存

vim clearcache.sh
#!/bin/bash
sync   # 一定要在下一步之前运行这个命令,用于保存buffer中的资料
echo "echo 1 > /proc/sys/vm/drop_caches"
# chmod 755 clearcache.sh
# crontab -e
0 3 * * * /path/to/clearcache.sh

清除交换空间和内存缓存

# swapoff -a && swapon -a
结合上面的脚本:
vim clearcache.sh
#!/bin/bash
sync   # 一定要在下一步之前运行这个命令,用于保存buffer中的资料
echo "echo 1 > /proc/sys/vm/drop_caches" && swapoff -a && swapon -a &&
printf \'\n%s\n\' \'Ram-cache and Swap Cleared\'

实例

[root@asiatop106 ~]# vim /opt/clearcache.sh 

#!/bin/bash
sync; echo 1 > /proc/sys/vm/drop_caches

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-08-25
  • 2021-12-06
  • 2021-06-07
猜你喜欢
  • 2021-09-12
  • 2021-12-02
  • 2022-01-21
  • 2022-02-07
  • 2021-08-08
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案