/logs/*/*-access.log /logs/*/*-error.log { create 0640 root support dateext daily rotate 40 missingok compress delaycompress notifempty postrotate fullname=`echo $1 | sed -r 's/\.log//'` basename=`basename $fullname` dirname=`dirname $fullname` date=`date +%Y%m` if [[ `date +%-d` -le 2 ]]; then date="" if [[ `date +%-m` -eq 1 ]]; then date="$((`date +%Y`-1))12" else date="`date +%Y`" month=$((`date +%-m`-1)) if [[ $month -le 9 ]]; then date=${date}0${month} else date=${date}${month} fi fi fi cd ${dirname} tar cfvz ${dirname}/${basename}-${date}.tgz ${basename}.log-${date}*.gz kill -HUP `cat /var/run/syslog-ng.pid` endscript }