- Peter Gradwell <[EMAIL PROTECTED]>:
| I'm using cyclog to log all qmail activity.
|
| When I delete all the log files
|
| rm /var/log/qmail/*
|
| it's using, it doesn't seem to recreate them until I restart qmail.
Oh, yes. But you just deleted the *current* log file, and cyclog
won't start a new one until the current one is full. Remember, that
you removed the file doesn't mean it's gone until all open file
descriptors on the file are closed.
cyclog marks its files done by turning off the write permission. So
the cure is to only remove files which are not writable. Just make
sure the qmail startup script does chmod -w /var/log/qmail/* since
there may be a writable file left over since the previous shutdown.
| I want to archive my log files daily:
|
| cat /var/log/qmail/* | gzip mylogs.gz
|
| and then delete the old ones
|
| but my rm attempt above doens't seem to be the best way.
|
| What's the best way to archive log files and remove the old ones?
On one of the machines I maintain, I have cyclog directories
/var/log/qmail and /var/log/smtpd, with corresponding directories
/var/log/qmailz and /var/log/smtpdz containing compressed logs.
User qmaill runs a cron job
15 2 * * * /var/qmail/etc/gzip_logs -quiet
where /var/qmail/etc/gzip_logs is as follows:
#!/bin/sh
if [ " $1 " = " -quiet " ]; then
exec >/dev/null
GZIP="/store/bin/gzip -9"
shift
else
GZIP="/store/bin/gzip -v -9"
fi
for d in qmail smtpd; do
echo Compressing from /var/log/${d} to /var/log/${d}z:
cd /var/log/${d}
[ -d ../${d}z ] || mkdir ../${d}z || exit 1
set -- *
while [ $# -gt 10 ]; do
if [ -w $1 ]; then
echo $1 'is writable; not touching it'
else
${GZIP} $1 && mv ${1}.gz ../${d}z
fi
shift
done
done
You may have to change some path names. Also, note that this job
keeps the last 10 log files uncompressed, for ease in checking the
lateste logs. I run cyclog with the arguments -s304000 -n30; you may
have to adjust these parameters. With a setup like this, there is
always a risk of losing log information if activity suddenly
skyrockets.
- Harald