how to processi log files before rotation.
Clarence Brown
clabrown at granitepost.com
Fri Jun 18 05:43:24 PDT 2004
2 questions ...
1. Where is the "right", or "standard" place to save shell
scripts that I want to use for administrative, or any other
tasks. Some place on the path I suppose.
2. I'd like to process my maillog and maillog.*.gz files just before
the maillog it is rotated into maillog.1.gz and maillog.7.gz is
discarded. I've written a couple of simple scripts to process the
files and report the number total number of messages blocked
with the DNSBL filters for today and the last 7 days, as well
as the numbers for each of the DNSBL lists that I use. It also
processes the maillog file and produces a total number blocked
for each user and emails that and a list of the messages blocked
to that user so that the user can check to make sure that they are
not missing "good" email.
I'd like to schedule the DNSBL status scripts to run every night
just before the maillog rotation happens. I've found where in
the /etc/crontab the log file rotation is scheduled, but I don't
know if there is a way to ensure that my status scripts start, and
run to completion before the logfile rotation starts.
As a test I added a couple of lines to run every 2 minutes to see
what order they executed in and found that the order of the lines
in crontab doesn't guarantee order of execution ... or at least completion
of the commands. The commands I added were more or less as follows:
*/2 * * * * root /root/dnsblstat
*/2 * * * * root mail -s "test line 1" my_email_addr
*/2 * * * * root mail -s "test line 2" my_email_addr
What I found was that the dnsblstat never completed before the two
following email commands, and sometimes the "test line 2" email
came in before the "test line 1".
As a brute force approach, I could schedule the dnsblstat to run some
number of minutes before midnight, to make sure it completed before
the log files were rotated "out from under it", but then I might miss a
few discards, and I wanted to show each user every email that was
discarded.
A different approach would be to process the maillog.1.gz file after
it is created, and to collect statistics for today and the last 6 days
instead of today and the last 7 days.
I sure this is a standard problem with a "correct" solution, so how
do you guys handle it?
Thanks, Cla. (sorry for the verbosity)
More information about the freebsd-questions
mailing list