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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s