ref: 92edb4bfea126fecf69586dec6a95bc52812283c
dir: /logrotate/
#!/bin/rc # # edit these 4 variables to your preference # 0 0 * * 0 $sysname /usr/glenda/bin/logrotate # logdir=/sys/log logfiles=(auth cpu cron dns gemini httpd/log listen mail runq smtp smtp.fail smtpd) generations=14 maxsize=1024000 if(! test -d $logdir){ echo $logdir does not exist exit } fn Rotate{ gen=$generations while(test $gen -ge '0'){ pgen=`{echo $gen - 1|bc} if(test -f $logdir/$1.$pgen.gz){ cp $logdir/$1.$pgen.gz $logdir/$1.$gen.gz chmod 0700 $logdir/$1.$gen.gz } gen=$pgen } gzip -c $logdir/$1 > $logdir/$1.0.gz rm -f $logdir/$i touch $logdir/$i chmod 0662 $logdir/$i chmod +a $logdir/$i } for(i in $logfiles){ if(test -f $logdir/$i){ size=`{du -n $logdir/$i|awk '{print $1}'} if(test $size -gt $maxsize){ Rotate $i } } }