We have a box where we get file every month on a particular folder. The files cud come any time and any day to the folder and the number of files is also not constant.
I have to write a script whjic will send mail to us on receving the files.
it mean any time one file comes, it will send an alert instantly with the name fo the file.
while :
do
# choose on of both below
LS1="$(ls -l | head -1 | cut -d' ' -f2)" # Total files
# LS1=$(stat $PWD -c %Y) # last modified
if [ $LS1 -gt $LS2 ]
then
# Put here the Mail procedure
fi
LS2=$LS1
sleep 5 # To check every 5 seconds (could be sleep 1m for 1 minute...)
done