Shell script with cronjob

Hello All,

I have a script which will cd into a directory based on current timestamp.
It will then do a grep and search for a condition. It's run on a cron job that runs every 30 minutes. So if it finds a match in 00, it sends out the contents of that grep to an alert and emails out. Now say, 01 comes around and nothing is in that file but the contents of 00 are still alerted and emailed out. I know it's doing that because it's repeating the grep from 00.. Is there a better way to do this grep? I'd hate to create 24 separate cronjobs for the same script based on timestamp.

#*/30 * * * 1,2,3,4,5 /pathtoscript.sh

cd /live/prod/`date +%Y/%m/%d`/prod/somedirectory/

the logs in somedirectory are based on GMT timestamp 

00  01  02  03  04  05  06  07  08  09  10  11  12  13  14

grep Order * |grep -i XFS* 

Your comments are greatly appreciated.

---------- Post updated at 01:53 PM ---------- Previous update was at 10:16 AM ----------

My apologies. I have a cronjob that runs every 30 minutes

*/30 * * * 1,2,3,4,5 /pathtoscript.sh

pathtoscript.sh consists of the following

cd /live/prod/`date +%Y/%m/%d`/prod/somedirectory/

COUNT=`grep Order *| wc -l`
OUT=`grep OrderToOrder * `

if [ "$COUNT" -eq 0 ]
then
  exit 1
else
  echo "$OUT" |mutt -s "\"Order FOUND, FYI, Please check\" " -- myemail.address.com
fi

exit 0

##Now on first run if a match is found in say 00 hr, if success it will email contents

When script runs again the next half hr, it will return the same results from 00.

Is there anyway to have the cron run again and not display the 00 output? The only other way i can figure it out is to have the same script but grep for diff hours. But then i would have to duplicate the script many times. Is there any other solution?

So, at hour 0 you want to email everything from the 0 folder to the 24 folder; but at hour 5, you only want to email everything from the 5 folder to the 24 folder?

What's the structure of your order files? One big, growing file with many orders, or one file per order?

EDIT: @Corona688: I don't think there are distinct directories per hour, but per day.

RudiC - The log file structure is below

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16, etc. These logs are based on GMT timestamp. In each log are many orders and entries.