I have a script that is sending email with directory tree when a new file is uploaded to server:
#!/bin/bash
SRC_DIR="/home/dir"
make_action(){
mutt -s "Subj" user@mail <<< $(tree "$SRC_DIR")
}
IFS='
'
inotifywait -e create --format '%w %f' -m -r $SRC_DIR |\
(
while read
do
make_action
done
)
But usually multiple files are uploaded, and the mail is received for every new file. How to make email to be sent only once, e.g., 2 minutes after the first file was uploaded?