/usr/local/nginx/logs/*.log {
    daily   
    dateext 
    rotate 1
    olddir  /usr/local/nginx/other/logs
    missingok  
    notifempty 
    compress 
    sharedscripts 
    postrotate
        /bin/kill -USR1 $(cat /var/run/nginx.pid 2>/dev/null) 2>/dev/null ||:
    endscript
    
}
dateext:文件后缀是日期格式,也就是切割后文件是:xxx.log-20150529(.gz) 这样,如果注释掉,切割出来是按数字递增,即前面说的 xxx.log-1(.gz)monthly: 日志文件将按月轮循。其它可用值为‘daily’,‘weekly’或者‘yearly’。rotate n: 一次将存储n个归档日志。对于第n=1个归档,时间最久的归档将被删除。compress: 在轮循任务完成后,已轮循的归档将使用gzip进行压缩。相反的命令是nocompressdelaycompress: 总是与compress选项一起用,delaycompress选项指示logrotate不要将最近的归档压缩,压缩将在下一次轮循周期进行。missingok: 在日志轮循期间,任何错误将被忽略,例如“文件无法找到”之类的错误。notifempty: 如果日志文件为空,轮循不会进行。相反命令ifempty是缺省值prerotate/endscript:在转储以前需要执行的命令可以放入这个对,这两个关键字必须单独成行postrotate/endscript:在转储以后需要执行的命令可以放入这个对,这两个关键字必须单独成行sharedscripts:所有的日志文件都轮转完毕后统一执行一次脚本olddir 转储后的日志文件放入指定的目录,必须和当前日志文件在同一个文件系统路径/etc/logrotate.conf为默认的配置路径,配置特定的日志处理,一般放在/etc/logrotate.d/下。在logrotate.conf中 使用include path包含对应路径
要调用为/etc/lograte.d/下配置的所有日志调用logrotate:
 
 logrotate /etc/logrotate.conf 
要为某个特定的配置调用logrotate
 
 logrotate /etc/logrotate.d/log-file 
排障过程中的最佳选择是使用-d选项以预演方式运行logrotate。要进行验证,不用实际轮循任何日志文件,可以模拟演练日志轮循并显示其输出。
 
logrotate -d /etc/logrotate.d/log-file
即使轮循条件没有满足,我们也可以通过使用-f选项来强制logrotate轮循日志文件,-v参数提供了详细的输出。
logrotate -vf /etc/logrotate.d/log-file
参考文档:
logrotate manual
Linux日志文件总管——logrotate
logrotate日志管理工具
原文:http://my.oschina.net/OpenSourceBO/blog/422375