Log rotation (unwanted.log, tally.unwanted)
Katsuhiro Kondou
Katsuhiro_Kondou at isc.org
Tue Jul 17 10:35:30 UTC 2001
In article <9iupvd$vmo$1 at krell.zikzak.de>,
Bettina Fink <laura at hydrophil.de> wrote;
} The only strange (?) thing I've noticed is that unwanted.log
} and OLD/unwanted.log.1.gz are identical. So if you want
} yesterday's stage of the unwanted.log, you'll need to access
} OLD/unwanted.log.2.gz. For all other logs files, yesterday's
} stage is the 1.gz version.
Yeah, it's different from older version. Attached(diff from
original one) should fix this also.
--
Katsuhiro Kondou
Index: scanlogs.in
===================================================================
RCS file: /home/kondou/news/inn/repository/inn/scripts/scanlogs.in,v
retrieving revision 1.3
diff -u -r1.3 scanlogs.in
--- scanlogs.in 2000/12/05 02:48:46 1.3
+++ scanlogs.in 2001/07/17 10:27:41
@@ -164,6 +164,34 @@
${SYSLOG_ERR})
mv ${F}.old ${OLD}/${BASE}
;;
+ ${UNWANTED_LOG})
+ ## Rotate and compress the file.
+ BASE=`basename ${F}`
+ if [ ! -f ${BASE} -a -f ../${BASE} ]; then
+ cp ../${BASE} ${BASE}
+ chmod 0440 ${BASE}
+ fi
+ if [ -f ${BASE} ]; then
+ ${LOG_COMPRESS} <${BASE} >${BASE}.0${Z} && rm -f ${BASE}
+ chmod 0440 ${BASE}.0${Z}
+
+ ## Do rotation.
+ if [ X${LOGCYCLES} = X ]; then
+ LOGCYCLES=3
+ fi
+ EXT=${LOGCYCLES}
+ rm -f ${BASE}.${LOGCYCLES}${Z}
+ while [ ${EXT} -gt 0 ] ; do
+ NEXT=${EXT}
+ EXT=`expr ${EXT} - 1`
+ test -f ${BASE}.${EXT}${Z} \
+ && rm -f ${BASE}.${NEXT}${Z} \
+ && mv ${BASE}.${EXT}${Z} ${BASE}.${NEXT}${Z}
+ done
+ fi
+ ## Innreport assumes where unwanted.log exists, so leave it
+ ## and process later.
+ ;;
*)
if [ -f ${F}.old ]; then
mv ${F}.old ${OLD}/${BASE}
@@ -241,6 +269,16 @@
echo ''
fi
rm -f ${OLD_LOG} ${OLD_SYSLOG}
+if ${ROTATE} ; then
+ BASE=`basename ${UNWANTED_LOG}`
+ if [ -f ${UNWANTED_LOG}.old ]; then
+ mv ${UNWANTED_LOG}.old ${OLD}/${BASE}
+ else
+ rm -f ${OLD}/${BASE}
+ cp ${UNWANTED_LOG} ${OLD}/${BASE}
+ chmod 0660 ${OLD}/${BASE}
+ fi
+fi
OLD_SYSLOG=${OLD}/${EXPLOG}.0
rm -f ${EXPLOG}
@@ -252,6 +290,10 @@
LOGCYCLES=3
fi
for F in ${LOGS} ; do
+ ## Skip if it's unwanted.log, since it's already rotated
+ if [ ${F} = ${UNWANTED_LOG} ]; then
+ continue
+ fi
## Skip if file doesn't exist.
BASE=`basename ${F}`
test -f ${BASE} || continue
More information about the inn-workers
mailing list