File modification monitoring via bash
There is a possiblity to monitor a set of directories or files to perform an action when it happens.
Basically, you register to monitor something on the kernel level and the kernel notifies the uppper layers when it happens.
Installation
1user $ sudo apt install inotify-tools
Example
Here is scrip example that monitors a directory and does something when something is added to that directory (-e create
):
1#!/usr/bin/env bash
2inotifywait -m -r -e create /data/tmp |
3while read path event file; do
4 case "$event" in
5 *ISDIR*)
6 echo "$path$file"
7 ;;
8 esac
9done