Last Updated: February 25, 2016
·
760
· spencerwi

Use inotify to respond to filesystem events

Inotify is Linux kernel subsystem that allows apps and scripts to "subscribe" to changes to a file and/or folder.

There are bindings for ruby, python, java, even nodejs.

It's great for writing daemons that react to new or changed files. Personally, I've used it to write a daemon to sort my wallpaper collection.

It's worth noting that inotify only works in Linux; for Mac OS X you'll want to use fsevents, and for Windows...good luck.

So next time you start to poll a folder in a script, consider if inotify can do the job more cleanly.