日志分割,系统日志分割,nginx日志分割/etc/logrotate.d

 /etc/logrotate.d
       实现nginx日志文件定时切割处理
       日志切割方法一: 利用脚本实现切割
       #!/bin/bash
       
       mv /var/log/nginx/access.log  /var/log/nginx/access_$(date +%F).log
       systemctl restart nginx
       日志切割方法二: 利用专用文件切割程序--logrotate
       vim /etc/logrotate.conf
       # rotate log files weekly
       weekly                     --- 定义默认日志切割的周期
       
       # keep 4 weeks worth of backlogs
       rotate 4                   --- 定义只保留几个切割后的文件
       
       # create new (empty) log files after rotating old ones
       create                     --- 创建出一个相同的源文件
       
       # use date as a suffix of the rotated file
       dateext                    --- 定义角标(扩展名称信息)
       
       # uncomment this if you want your log files compressed
       #compress                  --- 是否对切割后的文件进行压缩处理
       
       # RPM packages drop log rotation information into this directory
       include /etc/logrotate.d   --- 加载包含/etc/logrotate.d/目录中文件配置
       
       # no packages own wtmp and btmp -- we'll rotate them here
       /var/log/wtmp {            --- 单独对某个文件进行切割配置
           monthly
           create 0664 root utmp
              minsize 1M             --- 最小大小为1M,小于1M不进行切割              
           rotate 1
       }
       
       /var/log/btmp {
           missingok
           monthly
           create 0600 root utmp
           rotate 1
       }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值