1

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?

Michael
  • 5,095
  • 2
  • 13
  • 35
  • Will you want to call `make_action` again at all (say, at 2-minute intervals as long as files keep arriving)? – chepner Mar 16 '20 at 19:17

0 Answers0