entr(1)

Run arbitrary commands when files change

project page

entr uses 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 very low (on MacOS this usually 256).

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.

BSD

Modify /etc/login.conf

staff:\
:openfiles-max=16384:\
:openfiles-cur=4096:\

Mac

10.7 and before

Add the following line to /etc/launchd.conf

limit maxfiles 65536 524288

10.8

Add the following lines to /etc/sysctl.conf

kern.maxfilesperproc=65536
kern.maxfiles=524288

10.9+

Install a new property list file

cd /Library/LaunchDaemons
sudo curl -sO http://entrproject.org/etc/limit.maxfiles.plist

Linux

The maximum number of open files (per process) on most Linux distributions the is generous, and usually dos not need to be changed. To raised this limit, edit the following line in /etc/security/limits.conf

*       hard    nofile  16384

If others processes are also watching files you may an error such as “Unable to allocate memory” or “No space left on device”. In this case add the following line to /etc/sysctl.conf

fs.inotify.max_user_watches = 100000

Last updated on November 02, 2017
Send questions or comments to ericshane@eradman.com