Hi all,
I wrote this script to find files older than time parameter, count the number of files, and send an email to me that some files are in a particular folder. For the particular path, the script should wait delay parameter before running again.
For example, assuming the input file looks like this
20 A/B/ 5m
10 C/D 4m
The script changes dir to A/B, finds all files older than 20mins,counts them and sends an email to me.It then waits 5minutes before running again.It, however,keeps running to process the second path (C/D). It only waits if it found files older than the time parameter, otherwise it does nothing.It waits only for the path if found files, otherwise it keeps processing other paths.
I wrote something like this but doesnt seem to work
#!/bin/ksh
#The filepathinput format is 30 /A/B/C/gunner 10m
while read AGE PATH DELAY
do
cd $PATH
for file in $(ls)
do [[ $(( $(./fileage $file)/60)) -ge $AGE ]]
echo $file >>outputfiles.txt
done
final=`wc -l outputfiles.txt|awk '{print $1}'`
if $final -ge 1
then
echo $final|mailx -s "Unprocessed Files in blabla" gunner.love@henry.com
else
echo "Everything's OK"
fi
rm -f outputfiles.txt
sleep $DELAY
cd -
done < filepathinput.txt
Please advise.
Thank you