Hello All,
I wrote a shell script which monitors the FTP log file for new file uploads. Upon a file upload event, the script does some simple parsing of the log file entry and sends email.
Here is the stripped down version of the script:
However, instead of sending 1 message, the script sends many, in fact, the script sends dozens of messages for a single file upload event.
For testing purposes I added a loop counter which shows that the same log file entry is picked up by several consecutive cycles of the loop, hence a message is sent for each cycle.
What am I missing? Thanks for any good suggestions...
I wrote a shell script which monitors the FTP log file for new file uploads. Upon a file upload event, the script does some simple parsing of the log file entry and sends email.
Here is the stripped down version of the script:
Code:
#!/bin/sh
inotifywait -q -m -e modify $LOGFILE |
while true;
do
if tail -n 1 $LOGFILE | grep uploaded > /dev/null 2>&1
then
[process log file entry]
[send mail]
fi
done
However, instead of sending 1 message, the script sends many, in fact, the script sends dozens of messages for a single file upload event.
For testing purposes I added a loop counter which shows that the same log file entry is picked up by several consecutive cycles of the loop, hence a message is sent for each cycle.
What am I missing? Thanks for any good suggestions...