1828450 Members
4011 Online
109978 Solutions
New Discussion

Setup flags?

 
SOLVED
Go to solution
Coolmar
Esteemed Contributor

Setup flags?

Hi,

I have a script that monitors a log file and if it finds certain instance names (case loop) and under certain conditions (if loop)it will email people to clean up. It is monitoring all the time, so I want it to email them twice but after that stop emailing...then after a month start emailing again. Is there a way to do this?

Thanks,
2 REPLIES 2
Peter Godron
Honored Contributor
Solution

Re: Setup flags?

Hi,
I would have another file which holds the following:
1. Username
2. Count of mails
3. Month of last mail

Before you send a mail you check the count for the mailed user and the current month against the last mail month. If the months don't match (new month) you can set the count to 1 and send the mail. If the months match you only send the mail if the count is less than 3. Don't forget to update the count afetr sending the mail.
James R. Ferguson
Acclaimed Contributor

Re: Setup flags?

Hi:

One approach would be to create ('touch') a file whose name represents the user in question. Do this when you first email.

Maintain a unique directory for these files, so that you can do a 'find' that targets only these files. Use:

# find /path -name ${USER} -mtime +30

...when it returns a match signals a 30-day mark. Similarly, you can choose other day marks to control your behavior.

If the user in question has cleaned up his/her files, simply remove his/her timer-file from the directory.

Regards!

...JRF...