#!/bin/sh # trim huge news log files (> MAX_SIZE), preserve last 1000 lines of logs # in *.tail files for troubleshooting # # 1998-12-01 Rafael Skodlar MAX_SIZE=2000000 NEWS_LOG=/var/spool/news/var.log.news #NEWS_LOG=/var/log/news/ TMP=~/tmp NEWS=$TMP/news.logs BIG_NEWS=$TMP/big.news.logs #for file in (ls -l $NEWS_LOG | awk '{if($5 > $MAX_SIZE)print $9}}') /bin/ls -l $NEWS_LOG > $NEWS cat ${NEWS}|/bin/awk '{if($5 > 2000000)print $9}' > ${BIG_NEWS} for file in `cat ${BIG_NEWS}` do TAIL_FILE=${NEWS_LOG}/tails/$file.tail tail -1000 $NEWS_LOG/$file >$TAIL_FILE cp /dev/null $NEWS_LOG/$file echo trimmed log: $file done