- To: "Voytek" <lists@xxxxxxxxxx>
- Subject: Re: [SLUG] looping around directory name, yesterdays' date
- From: Michael Chesterton <chestie@xxxxxxxxxxxxxxx>
- Date: Mon, 02 Aug 2004 23:56:35 +1000
- Cc: slug@xxxxxxxxxxx
- User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3 (gnu/linux)
"Voytek" <lists@xxxxxxxxxx> writes:
> after I logresolve the original log, I'd like to delete the unresolved
> input log file(s)
> how do I asses error level of logresolve's succesfull completion before I
> rm the input log ?
This doesn't answer your question, but I would look in to how the log
files are rotated, there might be hooks to run logresolve, or a script
from there.
If not, another approach, which coincidently contains the answer to your
question
# get a list of logs directories, might not be the safest way to do it
# if there are a lot of directories in home, it might fail.
for DIR in `ls -d /home/*/logs`; do
# find *-access.log files that were last modified over a day ago
# we don't want to touch the current log file.
find $DIR -name '*-access.log' -mtime +1 | while read FILE; do
T=`basename ${FILE} .log`
ROG="${T}.rog"
# run logresolve and test if it was successful.
# The answer to your question
if logresolve < ${FILE} > ${ROG} ;then
rm ${FILE}
else
echo $0: error logresolving ${FILE}
fi
done
This is completely untested, it also relys on logresolve returning
true on success and false on failure. It will be a few days behind in
logresolving files, but you could fix that if you wanted to.