Monitor folder contents changes
Solution 1:
The inotify
kernel system is what you need.
-
Install
inotify-tools
:sudo apt-get install inotify-tools
-
Set up a watch:
inotifywait /path/to/directory --recursive --monitor
Sit back and watch the output.
From man inotifywait
:
-m, --monitor
Instead of exiting after receiving a single event, execute
indefinitely. The default behaviour is to exit after the first
event occurs.
-r, --recursive
Watch all subdirectories of any directories passed as arguments.
Watches will be set up recursively to an unlimited depth. Sym‐
bolic links are not traversed. Newly created subdirectories
will also be watched.
You can use the --event
option to watch for specific events, like creation, modification, etc.
Solution 2:
--events
is not the filter, you have to use --event
. For example, here's the command line for monitoring create/modify events:
# inotifywait . --recursive --monitor --event CREATE --event MODIFY
Then I see:
Setting up watches. Beware: since -r was given, this may take a while!
And here's the format of the feed:
[path] [event] [file]
e.g.
./.mozilla/firefox/b4ar08t6.default/ MODIFY cookies.sqlite-wal
./.mozilla/firefox/b4ar08t6.default/ MODIFY cookies.sqlite-wal
./.mozilla/firefox/b4ar08t6.default/ MODIFY cookies.sqlite-wal