Logrotate – 如何改变它,使它不会删除日志,并会每6个月创build一个.gz?

我看过那个男人 ,但我还不清楚。 我的问题主要与NGINXnetworking服务器日志有关。

这是我目前的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 # no packages own wtmp and btmp -- we'll rotate them here /var/log/wtmp { monthly create 0664 root utmp minsize 1M rotate 1 } /var/log/btmp { missingok monthly create 0600 root utmp rotate 1 } 

并在/etc/logrotate.d我也有其他人之间:nginx

 /var/log/nginx/*log { create 0644 nginx nginx daily rotate 10 missingok notifempty compress sharedscripts postrotate /bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true endscript } 

这些是.gz我可以看到的一些:

 access.log-20150430.gz access.log-20150509.gz (created after ~10 days) access.log-20150524.gz (created after ~15 days) access.log-20150528.gz (created after ~4 days) 
  1. 为什么.gz日志是如此频繁地创build,并且是在“随机”时间范围内?
  2. 我应该更改哪些内容,以便每6个月和/或.log文件创build新的.gz大于100MB?
  3. 使用旋转10这意味着,如果我已经有10个.gz文件,那么当它压缩11日,它会自动删除最古老的.gz文件? 如果是的话,我怎样才能避免删除日志文件? 即使很老,我也要把它们全部留下。
  4. 每日旋转10之间有什么区别?
  5. 这些文件的创build权限是否正常?
  6. 在更改logrotate.conf的内容之后,我应该重新启动某个服务,还是应立即应用这些更改?

我认为logrotate手册很清楚你的大部分观点。 这是我的答案:

  1. daily使用导致日志轮换daily发生。 所以,你需要检查为什么这不是每天都在发生。 例如,如果日志文件为空几天,则可能由其他选项notifempty引起。
  2. 我找不到每6个月就有一次的select,但是monthlyyearly 。 对于尺寸的困惑,你可以使用size 100M
  3. 是。 为了保持这一切,你可以select一个非常大的价值。
  4. daily指定旋转的频率,指定保存的日志文件的数量。
  5. 如果日志不包含敏感信息(其他人可以阅读),应该没问题。
  6. 不,你不需要重启任何东西。