[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-users] [OFF TOPIC] script to do cat /var/log/maillog | grep DENIED
- Subject: Re: [cobalt-users] [OFF TOPIC] script to do cat /var/log/maillog | grep DENIED
- From: "Steve Werby" <steve-lists@xxxxxxxxxxxx>
- Date: Wed Nov 7 05:41:01 2001
- Organization: Befriend Internet Services LLC
- List-id: Mailing list for users to share thoughts on Cobalt products. <cobalt-users.list.cobalt.com>
"Sean Chester" <sean.chester@xxxxxxxxxxxxxx> wrote:
> At the moment i type,
> cat /var/log/maillog | grep DENIED
>
> to see if there have been any mails denied today.
>
> Can someone make me a script that will do this for me at regular
> intervals? (and maybee send the results to email or html).
You can use that script, you just need to schedule it via cron. Follow
these steps.
1. su -
2. crontab -l (if output isn't blank add the output in step 3)
2. pico /root/cron.master
3. type the following: 2 1,7,13,19 * * * /path_to/your_script
4. ctrl-o, ctrl-x
5. crontab /root/cron.master
6. crontab -l (to verify that the cron file for root loaded)
Step 3 tells cron to run /path_to/your_script at 2 minutes after the hour at
the 1st, 7th, 13th and 19th hours of each day. The output of the script
will be emailed to the root user.
Replacing:
2 1,7,13,19 * * * /path_to/your_script
with:
2 1,7,13,19 * * * /path_to/your_script > /dev/null 2>&1
will cause the script to run without generating output.
Replacing it with:
2 1,7,13,19 * * * /path_to/your_script | mail -s "my subject here"
recipient@xxxxxxxxxx
will cause the email to be sent to the designated recipient.
Search google for a cron tutorial for more details. If you want to make
sure that the script doesn't analyze a time range previously analyzed you'll
want to:
Record the # of lines analyzed on each script run and the filesize of the
log and save to a file, then if the new filesize is greater than the old
jump down that many lines in the log before analyzing and if the filesize is
smaller analyze the whole log (because in that case it's likely the log was
just rotated so the previously analyzed lines are no longer in the log).
There might be a better way to do it, but that's off the top of my head and
what I'd use as a starting point.
--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/