【问题标题】:Need help in understanding logrotate behavior在理解 logrotate 行为方面需要帮助
【发布时间】:2012-12-18 18:43:28
【问题描述】:

/etc/logrotate.conf 说rotate logs "weekly"

/etc/logrotate.d/ssh 说

/var/log/ssh.log {
compress
dateext
maxage 120
rotate 99
missingok
notifempty
size +4096k
create 640 root p4admin
sharedscripts
postrotate
/etc/init.d/syslog reload
endscript
}

/var/lib/logrotate.status 表示上次旋转的 ssh 在“/var/log/ssh.log”2013-1-4

但以上与我们在文件中看到的数据不符...

-rw-r----- 1 root user 201M Jan 4 09:47 /var/log/ssh.log
-rw-r----- 1 root user 65M Oct 19 04:02 /var/log/ssh.log-20121019.gz
-rw-r----- 1 root user 64M Nov 28 04:02 /var/log/ssh.log-20121128.gz
-rw-r----- 1 root user 63M Oct 23 04:02 /var/log/ssh.log-20121023.gz

任何想法,我错过了什么?

【问题讨论】:

    标签: file logrotate


    【解决方案1】:
    • /etc/logrotate.conf 中的weekly 表示您的所有日志文件将每周轮换一次,如果此选项未在本地覆盖。

      手册说:

      Each configuration file can set global options (local definitions over-
      ride global ones, and later  definitions  override  earlier  ones)  and
      specify  logfiles  to  rotate.
      
    • 如果使用size 选项,logrotate 将忽略here 中所述的dailyweeklymonthlyyearly 选项

    • logrotate 每天执行一次,以检查大小等标准。如果适用,日志会同时轮换。

      手册说:

      Normally, logrotate is run as a daily cron job.  It will not  modify  a
      log  multiple  times  in  one  day unless the criterion for that log is
      based on the log's size and logrotate is being run multiple times  each
      day, or unless the -f or --force option is used.
      

    因此,logrotate 每天都会检查日志的大小,并在必要时执行轮换。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-11
      • 1970-01-01
      • 2011-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多