For clearing cache
[root@laptop ~]# free -h
total used free shared buff/cache available
Mem: 1.7G 944M 170M 113M 653M 492M
Swap: 6.5G 0B 6.5G
//653 M Exisit
[root@laptop ~]# sync; echo 1 > /proc/sys/vm/drop_caches
[root@laptop ~]# free -h
total used free shared buff/cache available
Mem: 1.7G 952M 456M 120M 360M 478M
Swap: 6.5G 0B 6.5G
cache has been reduced. only exist buffer
[root@laptop ~]# sync; echo 2 > /proc/sys/vm/drop_caches
[root@laptop ~]# free -h
total used free shared buff/cache available
Mem: 1.7G 946M 491M 121M 331M 499M
Swap: 6.5G 0B 6.5G
[root@laptop ~]# sync; echo 3 > /proc/sys/vm/drop_caches
[root@laptop ~]# free -h
total used free shared buff/cache available
Mem: 1.7G 952M 481M 126M 335M 488M
Swap: 6.5G 0B 6.5G
For clearing the swap simply use to trun off the swap and trun on it again the swap has been cleared
[root@laptop ~]# swapoff -a
[root@laptop ~]# swapon -a
//before clear swap make sure if any program doesn't run
//now make them altogether in single command
[root@laptop ~]# sync; echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a && printf '\n%s\n' 'cache ,swap, buffer cleared'
cache ,swap, buffer cleared
[root@laptop ~]# free -h
total used free shared buff/cache available
Mem: 1.7G 944M 170M 113M 653M 492M
Swap: 6.5G 0B 6.5G
//653 M Exisit
[root@laptop ~]# sync; echo 1 > /proc/sys/vm/drop_caches
[root@laptop ~]# free -h
total used free shared buff/cache available
Mem: 1.7G 952M 456M 120M 360M 478M
Swap: 6.5G 0B 6.5G
cache has been reduced. only exist buffer
[root@laptop ~]# sync; echo 2 > /proc/sys/vm/drop_caches
[root@laptop ~]# free -h
total used free shared buff/cache available
Mem: 1.7G 946M 491M 121M 331M 499M
Swap: 6.5G 0B 6.5G
[root@laptop ~]# sync; echo 3 > /proc/sys/vm/drop_caches
[root@laptop ~]# free -h
total used free shared buff/cache available
Mem: 1.7G 952M 481M 126M 335M 488M
Swap: 6.5G 0B 6.5G
For clearing the swap simply use to trun off the swap and trun on it again the swap has been cleared
[root@laptop ~]# swapoff -a
[root@laptop ~]# swapon -a
//before clear swap make sure if any program doesn't run
//now make them altogether in single command
[root@laptop ~]# sync; echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a && printf '\n%s\n' 'cache ,swap, buffer cleared'
cache ,swap, buffer cleared
0 Comments