Run arbitrary commands when files change

project page

kqueue(2) on BSD and Mac requires one file descriptor for each file and directory under watch. This poses a problem when watching a large code base since the default limit imposed by some operating systems is not very high.

Use the following instructions to set a default that is more reasonable for your use case. For simplicity, we assume that a reboot after changing configuration.


Modify /etc/login.conf



On MacOS 10.13 and later the file open limit is limited by the maxfiles kernel parameters

sysctl kern.maxfiles kern.maxfilesperproc

To raise this limit

sudo sysctl -w kern.maxfiles=100000
sudo sysctl -w kern.maxfilesperproc=50000


The maximum number of inotify watches may be set by setting the max_user_watches sysctl

cat /proc/sys/fs/inotify/max_user_watches

Make changes permanent by adding a file to /etc/sysctl.d/.