Artificial intelligent assistant

How to clear cache in Linux without flooding dmesg? I have a shell script which repeatedly clears the cache with echo 3 > /proc/sys/vm/drop_caches The trouble is that this ends up completely flooding dmesg because it runs so often. Is there a way to do this while suppressing the resulting kernel messages?

Yes, if you echo 4 to `drop_caches` first, subsequent `drop_caches` messages won’t be generated:


echo 4 > /proc/sys/vm/drop_caches


The setting is sticky and will remain until the system is rebooted.

See the last paragraph of the kernel documentation for `drop_caches`. Note also that, as explained in that documentation, dropping caches isn’t a good idea, and shouldn’t be done repeatedly; see also this commit.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 586d981a0a62a7eb4eabd28e6fb408c9