Created
January 27, 2012 22:06
-
-
Save offbeatadam/1691182 to your computer and use it in GitHub Desktop.
archiving irssi logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ROOTDIR="/home/triton/.irssi" | |
LOGDIR="$ROOTDIR/logs" | |
ARCHIVE="$ROOTDIR/logs.old" | |
printf "Beginning log archiving\n" | |
printf "Moving to log directory %s\n" "$LOGDIR" | |
cd $LOGDIR | |
for i in `ls -A` | |
do | |
if [ -d $i ] | |
then | |
printf "Moving to log subdirectory %s\n" "$i" | |
cd $LOGDIR/$i | |
for j in `ls -A` | |
do | |
if [ -d $j ] | |
then | |
printf "Current Working Directory: %s/%s/%s\n" "$LOGDIR" "$i" "$j" | |
cd $LOGDIR/$i/$j | |
for k in `find $PWD -type f -atime +7 -printf "%p\n"` | |
do | |
printf "Archiving File %s to %s/%s/%s\n" "$k" "$ARCHIVE" "$i" "$j" | |
cp -v "$k" "$ARCHIVE/$i/$j" | |
done | |
fi | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment