I have a ftp server where file will be ftped and processed and archived in archive once it's processed. The expected time for processing is 10 mins. I want to send an alert if any file is not processed and stays in ftp location for more than 10 mins.
#!/bin/bash
CYCLE=600 # seconds
if [ -d "$1" ]
then
INBOX=$1
else
echo "Usage: sh script [inbox]"
exit 1
fi
while (true)
do
NEW_LIST=$( ls -1 $INBOX )
if [ ${#NEW_LIST} -gt 0 ] && [ ${#OLD_LIST} -gt 0 ]
then
for ENTRY in $NEW_LIST
do
if [ $( echo "$OLD_LIST" | grep "$ENTRY" ) ]
then
echo "Delinquent: $ENTRY"
exit 2 # alert substitute
fi
done
fi
OLD_LIST=$NEW_LIST
sleep $CYCLE
done
# game over