blog.fridns.se

Free Cache - Drop_caches as Nonroot

| Comments

The other day I got a request from a developer at our company regarding drop_caches. You can read about what it is and why it could be useful here, but to make it short, this person wanted to do some benchmarking and needed the page/inode/dentry cache to be freed. Since this is needed to be done by root, this caused a problem (developer is not root, our infrastructure setup doesn’t allow our developers to be root atm). Although I came up with a pretty neet sudo rule that does the job,

1
/sbin/sysctl -w vm.drop_caches=[1-3]

Just put the above command in /etc/sudoers for affected users and they should be able to free page/inode/dentry cache as they wish.

Keep it simple.