ref: 0165e83598f06c10aabf676e5798d84f9a464510
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 chmod -a $logdir/$i >$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 } } }