1. 程式人生 > >CentOS7(Linux)清理yum快取 和釋放記憶體方法

CentOS7(Linux)清理yum快取 和釋放記憶體方法

清理yum快取

清理yum快取使用yum clean 命令,yum clean 的引數有headers, packages, metadata, dbcache, plugins, expire-cache, rpmdb, all

yum clean headers  #清理/var/cache/yum的headers
yum clean packages #清理/var/cache/yum下的軟體包
yum clean metadata
...

Linux釋放記憶體

釋放網頁快取(To free pagecache):

sync; echo 1 > /proc/sys/vm/drop_caches

釋放目錄項和索引(To free dentries and inodes):

sync; echo 2 > /proc/sys/vm/drop_caches

釋放網頁快取,目錄項和索引(To free pagecache, dentries and inodes):

sync; echo 3 > /proc/sys/vm/drop_caches

下面是我實際的資料。

[[email protected] ~]# free -m    #檢視記憶體
              total        used        free      shared  buff/cache   available
Mem:
481 224 120 1 136 202 Swap: 1023 283 740 [[email protected] ~]# sync; echo 3 > /proc/sys/vm/drop_caches [[email protected] ~]# free -m #從120到186,釋放了66m的記憶體 total used free shared buff/cache available Mem:
481 209 186 1 85 222 Swap: 1023 283 740