Prevent file from being mailed multiple times from a job

We have a ksh which runs once every 15 minutes. Based on a certain condition (for invalid data) we are spooling a file and if the file is of length greater than 0 bytes, then we are mailing this file to a group of users. Upon receiving the file, users correct the data so that on its next run the same data is not selected and the file spooled becomes 0 bytes and hence is not mailed across.
But, it mostly happens that users take more than 15 minutes to correct the data and hence this job creates the same file and mails it to the uses again.

What I am looking for, is there a counter logic which I can set and which will allow me to send the file only once of it is greater than 0 bytes.

Best would be - once the file is created with more than 0 bytes for the first time, it will be sent only once(i.e for the first time) and after that, say, for the next 2 hours( which implies 7 more cycles), this file, even if gets created will never be mailed at all.

Thanks,
Sree

You could, when you mail the file, move it to file.old and then in the next run, if there is a file.old, compare it to the new file that is just made. If they are the same, don't mail it. If they are different, add the new changes to the file.old and send/mail the new changes and then move the new one to file.old. This way, you don't lose any info that needs to be corrected, the users will be getting data that is new.

Once you have a run with no changes (zero bytes), you could remove file.old for future runs.

Hi,

Thanks RTM. This seems to be the best solution so far. I have designed the flow of the algorithm based on this solution - here it goes -

--*******************************************--
| Non-Repeating Mailing Logic in the program: |
--*******************************************--

---------------------------------------------------------
|BEGIN PROCESSING BLOCK:				|
---------------------------------------------------------


Check for existence of File A_Old created on the previous day.
 
 If File A_Old was created on the previous day, then
 
    Remove File A_Old.
 
 Else, 

1. Create File A.

If File A > 0 bytes, then

   2. Check whether File A_Old exists or not.
   
   If File A_Old does not exist, then     -- (this implies this is the first time mailing process)
   
   2a(i). Copy File A to File A_Old.
   2a(ii). Mail File A to the users.
   2a(iii). Remove File A.
   
   If File A_Old does exist, then      -- (this implies we might have already mailed the Rejects file)
   
   2b. Compare File A with File A_Old.
   
       If both the files are the same, then
       
       2b(i). Skip Mailing process.
       
       If the files are different, then
       
       2b(ii). Copy File A to File A_Old.
       2b(iii).Mail File A.
       2b(iv). Remove File A.

If File A = 0 bytes, then

   Skip entire mailing process.
   
---------------------------------------------------------
|END PROCESSING BLOCK:					|
---------------------------------------------------------

However, for this to go right, I need to know how can I find whether a file is created on the previous day or not(i.e in any way can the file creation timestamp be retrieved and comapared against the current date), if the timestamp is of the last day, then I would be deleting the old file, otherwise retain it.

Thanks again, RTM .

-
Sree