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.
Written by Spencer Williams
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#