Inotify is a Linux subsystem which monitors the filesystem for changes, and provides a way to trigger actions when it does.

This is handy, since it means that your program/demon can avoid polling for changes constantly, making it more efficient and reliable. As an aside, this is how the Linux Dropbox tool works.

I was reminded of its existence by a recent hacker news article, so I decided to have a little play over lunch. Here is a little toy I hacked together which monitors a directory for text files containing URLs. When it detects a new one the script retrieves it via WGET and deposited in a nominated downloads directory.

This is a trivial use of the technology, although it is still quite useful, letting me trigger large downloads via my phone or ipad which then get automatically fetched by my NAS without the need to fire up my desktop machine.

» Visit the project on Github…

Image by Oxygen Team, used under the GPL2 licence.

One thought on “Playing around with inotify

  1. cool good stuff, Marcus.. mebbe u left us @elgg comm, but however.. (some of us) just will *not leave you be 😉 u r as always.. good reading and synapse-triggering. i’ve used some of yr techie columns’ advice and tips in ‘top secret’ non-gpl utlities.. why ? why not! works & neat; and also makes me think mucho harder towards more effort. this i have learnt from your form. ThX & Cheers.

Leave a Reply