Monthly Archives: May 2016

Watching directories for file changes with inotifywait.

Diary of a daydreamer

I was in need for a quick script that would monitor a certain directory for file changes.

The case is a quite easy one: I own a directory where the results of certain simulations are stored. As I wanted to know when a new simulation begins and what is the number of simulations already finished, I decided to take a look at the way I could handle with this new challenge.

The first attempt was an easy one, using time delays and commands like $ ls -1 | wc -l and of course $ sleep. However this was quite annoying as i kept getting multiple indications for the same number of simulation results. Then, I discovered a package named inotify-tools. inotify-tools contains several useful commands that take advantage of the inotify events dispatched by the respective Linux kernel subsystem. I am not going to list the uses of…

View original post 277 more words