Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # it removes entries older than 7 days from most common log files - having to add in qmail
- # and other formats also and have it run from a cron job.
- skiplog="access_log error_log bruteforceip rkhunter.log rkhunter.log.old anaconda.log brcm-iscsi.log datec2.sh datec.sh anaconda.syslog lastlog btmp dmesg lastlog mysqld.log rpmpkgs tallylog tallylog xferlog"
- pathto="$?"
- logfiles="${?}*"
- match="0"
- for d in $logfiles; do
- for c in $skiplog;do
- echo "checking for matches of $c and $d"
- b=`echo $d | sed 's/\// /g' | awk '{ print $3 }'`
- echo "$d $c $b"
- if [ "$c" == "$b" ];then
- echo "skipping $b"
- match="1"
- break
- else
- match="0"
- fi
- done
- if [ $match == "0" ];then
- echo "processing $d"
- while read line; do
- date=`echo $line | awk '{ print $2 }'`
- curdate=`date | awk '{ print $3 }'`
- let "num1=10#${date}"
- let "num2=10#${curdate}"
- if [ $num1 != "" ]; then
- math=$(( $num1 + 7 ))
- if [ $num1 == $num2 ] || [ $math -gt $num2 ];then
- echo $line >> ${d}.tmp
- echo $line
- fi
- if [ -e ${d}.tmp ];then
- mv ${d}.tmp ${d}
- fi
- fi
- done < $d
- match=0
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment