2014-04-01 211 views
5

如何限制由syslog管理的日誌文件的總大小?當這個大小限制(配額)超過時,最舊的歸檔日誌文件可能應該被刪除。如何限制由syslog管理的日誌文件的總大小?

某些日誌文件是由LOG_LOCALn指定的自定義文件,但我想這與配額問題無關。

謝謝!

+2

配置logrotate。一些syslog化身在內部支持logrotating。 – user3159253

回答

-1

Linux實用程序logrotate定期重命名和重新使用系統錯誤日誌文件,以免它們佔用過多的磁盤空間。 Linux系統將關於此的所有相關信息存儲到文件中/etc/logrotate.conf

有許多屬性可幫助我們管理日誌大小。在做任何事之前請閱讀手冊(「man logrotate」)。在我的機器這個文件看起來如下:

# see "man logrotate" for details 
# rotate log files weekly 
weekly 

# keep 4 weeks worth of backlogs 
rotate 4 

# create new (empty) log files after rotating old ones 
create 

# uncomment this if you want your log files compressed 
#compress 

# packages drop log rotation information into this directory 
include /etc/logrotate.d 

# no packages own wtmp, or btmp -- we'll rotate them here 
/var/log/wtmp { 
    missingok 
    monthly 
    create 0664 root utmp 
    rotate 1 
} 

/var/log/btmp { 
    missingok 
    monthly 
    create 0660 root utmp 
    rotate 1 
} 

# system-specific logs may be configured here 

正如我們可以看到,日誌文件將在每週basis.This旋轉,可以改變每天basis.The敷在我的機器上沒有啓用。如果您想使日誌文件的大小更小,可以啓用此功能。 有很好的article你可能想參考完整的理解這個話題。