How to set and understand fs.notify.max_user_watches

sysctl -w writes kernel parameter values to the corresponding keys under /proc/sys:

sudo sysctl -w fs.inotify.max_user_watches=12288

writes 12288 to /proc/sys/fs/inotify/max_user_watches. (It’s not equivalent, it’s exactly that; interested readers can strace it to see for themselves.)

sysctl -p

loads settings from a file, either /etc/sysctl.conf (the default), or whatever file is specified after -p.

The difference between both approaches, beyond the different sources of the parameters and values they write, is that -w only changes the parameters until the next reboot, whereas values stored in /etc/sysctl.conf will be applied again every time the system boots. My usual approach is to use -w to test values, then once I’m sure the new settings are OK, write them to /etc/sysctl.conf or a file under /etc/sysctl.d (usually /etc/sysctl.d/local.conf).

See the sysctl and sysctl.conf manual pages (man sysctl and man sysctl.conf on your system) for details.

Tags:

Linux

Sysctl