The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,311 other followers

Using inotify-wait to check filesystem events

Posted by jpluimers on 2014/07/21

Thanks to Using inotify-wait to check filesystem events I got pointed to How to use inotify-tools to trigger scripts on filesystem events which is now on my research list.

–jeroen

Note that Kristian later on commented this:

The solution shown in the article has race conditions and should not be used.

It is based on

while :
do
inotifywait $options && run-backup
done

and that means that while the backup runs, the directory in question is unmonitored. When the backup finishes, new changes may have been accumulating during backup run, but without being picked up by the backup.

A proper solution would do something like

inotifywait -m $options | while read line
do
do-something-that-logs-multile-changes-and-triggers-backup-once
done

The important thing is that “inotifywait -m” does not terminate and hence no changes will be lost. It is wrong to run the backup once in full for each change, though.

 

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

 
%d bloggers like this: