NOCACHE(1)
π NOCACHE π
okay bestie, so this is nocache, from section 1 of the manual (you know, the "just run it in your shell" section β¨). It does exactly what it says on the tin: it stops a command from trashing your Linux page cache. Your filesystem will literally thank you. π«Ά
πΈ NAME πΈ
nocache β don't use Linux page cache on given command. periodt. π
β¨ SYNOPSIS β¨
nocache [-n <n>] command [argument...]
π OPTIONS π
-n <n>"Set number of fadvise calls" β this makes it run theposix_fadvisesystem call <n> times back to back, in a row, no breaks. Depending on your machine this might give better results β so use it if in your testsnocachefails to eradicate pages from cache properly. (yeah, sometimes one fadvise just isn't enough, she needs to be told <n> times. iconic honestly. π)
π¦ DESCRIPTION π¦
okay so here's the tea β β nocache tries to minimize the effect an application has on the Linux file system cache. The way it does this is by intercepting the open and close system calls and calling posix_fadvise with the POSIX_FADV_DONTNEED parameter. slay. π₯
and the reason it remembers stuff is: the library remembers which pages (ie., 4K-blocks of the file) were already in file system cache when the file was opened. Those ones will not be marked as "don't need", because other applications might need that, even though they are not actively used (think: hot standby). so it's not out here evicting your friend's stuff. it's giving considerate. π
π ALTERNATIVE: HOW TO USE CGROUPS TO RESTRICT CACHE USE π
if your use case is a backup process that should not interfere with the present state of the cache too much, lowkey consider using cgroups instead. They're much cleaner and carry less overhead than this tool. no cap. β¨
for example, if your system uses systemd, you can do:
systemd-run --scope --property=MemoryLimit=500M -- backup command
for more info, see the README on https://github.com/Feh/nocache π
π«Ά little reminder bestie: cgroups are the cleaner, lighter-overhead option when it's a backup process that shouldn't be messing with the current state of the cache too much. nocache is still the moment for everything else tho. π
and that's the whole page!! this one's nocache, in the NOCACHE(1) manual, from March 2013 β go forth and keep your cache clean, main character. ππΈπ
π¦ where this page comes from
- debian trixie: nocache 1.2-0.1 Β· BSD-2-Clause
- ubuntu questing: nocache 1.2-0.1
- ubuntu resolute: nocache 1.2-0.1build1 Β· BSD-2-Clause
- ubuntu stonking: nocache 1.2-0.1build1 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms