Tuesday, 9 January 2018

Linux from the command line | Linux for sysadmins -- Triggering events with inotify

Linux from the command line | Linux for sysadmins -- Triggering events with inotify

This is a big deal feature and an important skill. There are a few ways to trigger things based on certain events happening in Linux. For example, running a script when a file is written to a certain directory. Think of automatically backing up log files to another system and deleting old logs.
http://www.linuxjournal.com/content/linux-filesystem-events-inotify

2 comments:

  1. This is handy. The article spends some time lamenting the fact that an "inotifywait... | while read...; done" pipeline executes the while-loop in a subshell, effectively losing variable assignments. The behavior is not a bug. The way to get what you want is to structure the pipeline so that the while-loop is first: "while read...; done < <(inotifywait...)"

    ReplyDelete
  2. Adrian Colley submit the fix. They'll likely post it.

    ReplyDelete