I am checking that a file is older than a reference file that I build with a touch command before processing it. If it is not old enough, I want to sleep for an hour and check again.
My problem is if it is old enough to process, I want to exit when I am done, but I cannot find a way to exit after doing a successful find. It keeps looping and processing until the count is fulfilled. I have tried doing an exit as a -exec on the find as shown below and I have tried checking the status of the find with $?, but it is always "0" whether the file is old or new.
Any ideas?
typeset -i count=1
while ((${count} <= 3))
do
find /export/home/MYACCT/ -type f -name \ar5.log ! -newer /WORKDIR/REF -exec /export/home/MYACCT/datetest.ksh \; -exec exit 0 \;
count=${count}+1
sleep 3600
done
echo "No file to process"
exit 5