Issue
Recently I tried to empty the buffers cache on a Debian webserver. The command I used was:
free && sync && echo 3 > /proc/sys/vm/drop_caches && free
So far so good, running cat /proc/sys/vm/drop_caches
prints a value of 3.
When I try to reset the value to 0 with sync && echo 0 > /proc/sys/vm/drop_caches
, this error shows:
bash: echo: write error: Invalid argument
Which is due to drop_caches
being a command, not a variable to be set. I found this:
sudo sysctl -w vm.drop_caches=3
It immediately clears the pagecache, dentries and inodes and clears again only if you call sysctl -w
again, there is no need to apparently set it back to 0 in an explicit manner. The command sysctl
is not natively supported on Debian so I'm looking for an alternative command, more precisely:
How to reset drop_caches or immediately empty the cache to reset the value to 0?
Solution
The values 1-3 are just one time trigger for action. There is no value 0.
sysctl is in package procps .
apt install procps
Answered By - lbor Answer Checked By - Mary Flores (WPSolving Volunteer)