I am trying to automate my log handling for several scripts that are running. And the worst thing is a I am newbie as you can see by the script.
I want to retain 3 days worth of logs, anything greater then 3 I want delete.
is there a way I can do this?
#!/bin/bash
DATE=`eval date +%m%d%y`
SUFFIX=$DATE
# logs are formatted as: $SUFFIX-*-backup.log
logcount=`ls *-*error.log |wc -l`
#for this test I only want to keep 3 historical logs
until [ $logcount -lt 3 ]; do
logcount=$(($logcount - 1))
SUFFIX=$(($SUFFIX - 000300))
echo "Removing "$DATE".log"
rm -R $SUFFIX*.log
done
getting error on:
SUFFIX=$(($SUFFIX - 000300))
And I am stumped... any suggestion / hints / etc.. would be greatly appreciated. Back to