2013-01-04 146 views
2

/etc/logrotate.conf中說:rotate logs "weekly"理解logrotate的行爲需要幫助

/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 

任何想法,我錯過了什麼?

回答

1
  • weekly/etc/logrotate.conf意味着所有的日誌文件將每週輪換,如果這個選項未在本地覆蓋。

    手冊上說:

    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的將忽略dailyweeklymonthly,並yearly選項說明here

  • 日誌輪播每天執行以檢查尺寸等標準。如果適用,日誌會同時旋轉。

    手冊上說:

    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的檢查日誌日常的大小,它在必要時進行轉動。