2016-11-15 34 views
4

日誌輪播不轉動我的日誌日誌輪播:登錄不需要旋轉

要驗證該日誌文件不爲空:

# ls -laFh /var/log/cisco-meraki.log 
-rw-r----- 1 root adm 2.8G Sep 5 13:23 /var/log/cisco-meraki.log 

配置(/etc/logrotate.d/zzzzz_default):

"/var/log/cisco-meraki.log" { 
    daily 
    rotate 10 
    compress 
    missingok 
    notifempty 
    create 
} 

全局配置(logrotate.conf):

daily 
rotate 10 
create 
include /etc/logrotate.d 
/var/log/wtmp { 
    missingok 
    monthly 
    create 0664 root utmp 
    rotate 1 
} 
/var/log/btmp { 
    missingok 
    monthly 
    create 0660 root utmp 
    rotate 1 
} 

嘗試手動運行:

# logrotate --verbose -d zzzzz_default 
reading config file zzzzz_default 

Handling 1 logs 

rotating pattern: "/var/log/cisco-meraki.log" after 1 days (10 rotations) 
empty log files are not rotated, old logs are removed 
considering log /var/log/cisco-meraki.log 
    log does not need rotating 

要驗證這個問題是不是 「媒體鏈接旋轉」 我查了一下:

# cat /var/lib/logrotate/status|grep cisco 
"/var/log/cisco-ace.log" 2016-1-19-16:0:0 
"/var/log/cisco-pix.log" 2016-1-19-16:0:0 
"/var/log/cisco-acs.log" 2016-1-19-16:0:0 
"/var/log/cisco-asa.log" 2016-1-19-16:0:0 
"/var/log/cisco-router.log" 2016-9-6-0:1:1 
"/var/log/cisco-ips.log" 2016-1-19-16:0:0 

..但沒有思科meraki.log

回答

0

從日誌輪播手冊頁:

 -d, --debug 
      Turns on debug mode and implies -v. In debug mode, no 
      changes will be made to the logs or to the logrotate 
      state file. 

我碰到了完全相同的問題!

N.

0

看到https://unix.stackexchange.com/a/96947

比方說,你今天創建了zzzzz_default文件。 logrotate將創建一個條目,就好像它今天在/ var/lib/logrotate/status中旋轉日誌一樣。

當您運行當今logrotate --verbose -d zzzzz_default logrotate的檢查上一次旋轉日誌閱讀的/ var/lib中/ logrotate的/狀態。它會發現它創建該條目之前,所以它會說

如果你明天就要跑logrotate --verbose -d zzzzz_default logrotate的檢查上一次旋轉日誌閱讀的/ var/lib中/ logrotate的/狀態。它會不是找到該條目,因此它會旋轉日誌文件。