Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

This script checks recent upload from one of my server which naming convention is pretty much standard ending with today’s date.

This script can be used as tip to use loop read (content inside some directory), Email notification.

#!/bin/bash
#### Directory variable####
LOG_DIR='/data/1/ /data/2/ /data/3/


##### Email notification if failure##########
RCPT="tikejhya@ashishnepal.com"


##### Loop starts here############

for i in $LOG_DIR;do
        file=`ls -lrt $i | grep -i `date +%Y-%m-%d --date='1 day ago'`_23 | tail -5 | wc -l`

        if [ $file -ne 0 ];then

        echo "File Were uploaded $i" >> /data/logs/upload_success



                else

                                echo "Alert: Files are Not uploaded for $i" >> /data/logs/uploads_error
                                echo "Files not uploaded to $i for `date +%Y-%m-%d --date='1 day ago'`" | mail -s "ATTENTION" $RCPT

fi
done
exit 0