![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to prevent multiple email notifications from monitoring script | si_linux | Shell Programming and Scripting | 2 | 06-07-2007 05:55 AM |
| Trying to read data multiple times | coachr | Shell Programming and Scripting | 1 | 12-14-2006 08:19 PM |
| Trying to read data multiple times | coachr | Shell Programming and Scripting | 0 | 12-06-2006 02:11 PM |
| Locking a file when using VI to prevent multiple-edit sessions by diff users | Browser_ice | AIX | 14 | 11-23-2006 10:43 AM |
| matching multiple times in same line | oldtrash | Shell Programming and Scripting | 2 | 04-28-2004 05:57 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
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 - Code:
--*******************************************--
| 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: |
---------------------------------------------------------
Thanks again, RTM . - Sree |
| Sponsored Links | ||
|
|