在工做中须要切割日志咱们项目中选择的系统自带的logrotate,如须要其余需求须要本身在百度一下或者参考:html
http://www.javashuo.com/article/p-rzhvcmfk-m.htmlpython
#centos7 切割 /data/nginx/logs/access.log { su root root daily #指定转储周期为天天 missingok #若是日志丢失,不报错继续滚动下一个日志 rotate 360 #指定日志文件删除以前转储的次数,0 指没有备份,360指保留360 个备份 compress #经过gzip 压缩转储之后的日志 delaycompress #和compress 一块儿使用时,转储的日志文件到下一次转储时才压缩 notifempty #当日志文件为空时,不进行轮转 dateext #使用当期日期做为命名格式 copytruncate #用于还在打开中的日志文件,把当前日志备份并截断;是先拷贝再清空的方式,拷贝和清空之间有一个时间差,可能会丢失部分日志数据。 } #centos6和ubuntu /data/nginx/logs/access.log { daily missingok rotate 360 compress delaycompress dateext notifempty copytruncate }