Posted on 2012-06-26 16:07
Milo的海域 閱讀(313)
評論(0) 編輯 收藏 所屬分類:
Linux
1. 配置


compress 通過gzip 壓縮轉儲以后的日志
nocompress 不需要壓縮時,用這個參數
copytruncate 用于還在打開中的日志文件,把當前日志備份并截斷
nocopytruncate 備份日志文件但是不截斷
create mode owner group 轉儲文件,使用指定的文件模式創建新的日志文件
nocreate 不建立新的日志文件
delaycompress 和 compress 一起使用時,轉儲的日志文件到下一次轉儲時才壓縮
nodelaycompress 覆蓋 delaycompress 選項,轉儲同時壓縮。
errors address 專儲時的錯誤信息發送到指定的Email 地址
ifempty 即使是空文件也轉儲,這個是 logrotate 的缺省選項。
notifempty 如果是空文件的話,不轉儲
mail address 把轉儲的日志文件發送到指定的E-mail 地址
nomail 轉儲時不發送日志文件
olddir directory 轉儲后的日志文件放入指定的目錄,必須和當前日志文件在同一個文件系統
noolddir 轉儲后的日志文件和當前日志文件放在同一個目錄下
prerotate/endscript 在轉儲以前需要執行的命令可以放入這個對,這兩個關鍵字必須單獨成行
postrotate/endscript 在轉儲以后需要執行的命令可以放入這個對,這兩個關鍵字必須單獨成行
daily 指定轉儲周期為每天
weekly 指定轉儲周期為每周
monthly 指定轉儲周期為每月
rotate count 指定日志文件刪除之前轉儲的次數,0 指沒有備份,5 指保留5 個備份
tabootext [+] list 讓logrotate 不轉儲指定擴展名的文件,缺省的擴展名是:.rpm-orig, .rpmsave, v, 和 ~
size size 當日志文件到達指定的大小時才轉儲,Size 可以指定 bytes (缺省)以及KB (sizek)或者MB (sizem).
2. 命令行選項


OPTIONS
-v Turn on verbose mode.
-d Turns on debug mode and implies -v. In debug mode, no changes will be made to the logs or to the logrotate state file.
-f, --force
Tells logrotate to force the rotation, even if it doesn’t think this is necessary. Sometimes this is useful after adding new
entries to logrotate, or if old log files have been removed by hand, as the new files will be created, and logging will con-
tinue correctly.
-m, --mail <command>
Tells logrotate which command to use when mailing logs. This command should accept two arguments: 1) the subject of the mes-
sage, and 2) the recipient. The command must then read a message on standard input and mail it to the recipient. The default
mail command is /bin/mail -s.
-s, --state <statefile>
Tells logrotate to use an alternate state file. This is useful if logrotate is being run as a different user for various sets
of log files. The default state file is /var/lib/logrotate.status.
--usage
Prints a short usage message.
選項-d 用來打開debug模式
選項-v 用來打開verbose模式
選項-f 用來打開強制選項,會強制發生log rotate即使不滿足條件
debug模式跟verbose的區別就是: debug模式是dry-run版本的verbose模式,一般用來調試新加的logroate配置文件, 比如:
/usr/sbin/logrotate /etc/logrotate.d/NEWCONFIG -df
/usr/sbin/logrotate /etc/logrotate.d/NEWCONFIG -vf