The Linux System has three options to clear cache without interrupting any processes or services.
To clear all PageCache, entries, and inodes you need to use something like:
1 | # sync; echo 3 > /proc/sys/vm/drop_caches |
The drop_caches file can be changed by echo command with these numbers: 1,2 and 3.
To clear the Swap space, you may like to run the below command.
1 | # swapoff -a && swapon -a |
You can create one single command to clear RAM Cache and Swap Space, see:
1 | echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a && printf '\n%s\n' 'Ram-cache and Swap Cleared' |