「Logrotate」の版間の差分
提供: Wikinote
(ページの作成:「== 設定 == === デフォルト === logrotate-3.7.4-8 (CentOS 5.2) の /etc/logrotate.conf の内容は以下。 weekly rotate 4 create #compress include /etc/logro...」) |
|||
行8: | 行8: | ||
#compress | #compress | ||
include /etc/logrotate.d | include /etc/logrotate.d | ||
+ | |||
+ | == 動作 == | ||
+ | |||
+ | === copytruncate === | ||
+ | |||
+ | 以下の設定の場合。 | ||
+ | rotate 4 | ||
+ | copytruncate | ||
+ | |||
+ | strace を取ってみると、過去ログを rename した後に、 | ||
+ | open して read/write によるコピー、その後 ftruncate。 | ||
+ | |||
+ | rename("/root/stap/test.log.4", "/root/stap/test.log.5") = -1 ENOENT (No such file or directory) | ||
+ | rename("/root/stap/test.log.3", "/root/stap/test.log.4") = -1 ENOENT (No such file or directory) | ||
+ | rename("/root/stap/test.log.2", "/root/stap/test.log.3") = -1 ENOENT (No such file or directory) | ||
+ | rename("/root/stap/test.log.1", "/root/stap/test.log.2") = 0 | ||
+ | rename("/root/stap/test.log.0", "/root/stap/test.log.1") = -1 ENOENT (No such file or directory) | ||
+ | access("/root/stap/test.log.5", F_OK) = -1 ENOENT (No such file or directory) | ||
+ | open("/root/stap/test.log", O_RDWR|O_LARGEFILE) = 3 | ||
+ | open("/root/stap/test.log.1", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0100644) = 4 | ||
+ | fchmod(4, 0600) = 0 | ||
+ | fchown32(4, 0, 0) = 0 | ||
+ | fchmod(4, 0100644) = 0 | ||
+ | read(3, "1308784634\n1308784635\n1308784636"..., 8192) = 319 | ||
+ | write(4, "1308784634\n1308784635\n1308784636"..., 319) = 319 | ||
+ | read(3, "", 8192) = 0 | ||
+ | ftruncate64(3, 0) = 0 | ||
+ | close(3) = 0 | ||
+ | close(4) = 0 |
2011年6月23日 (木) 08:22時点における版
設定
デフォルト
logrotate-3.7.4-8 (CentOS 5.2) の /etc/logrotate.conf の内容は以下。
weekly rotate 4 create #compress include /etc/logrotate.d
動作
copytruncate
以下の設定の場合。
rotate 4 copytruncate
strace を取ってみると、過去ログを rename した後に、 open して read/write によるコピー、その後 ftruncate。
rename("/root/stap/test.log.4", "/root/stap/test.log.5") = -1 ENOENT (No such file or directory) rename("/root/stap/test.log.3", "/root/stap/test.log.4") = -1 ENOENT (No such file or directory) rename("/root/stap/test.log.2", "/root/stap/test.log.3") = -1 ENOENT (No such file or directory) rename("/root/stap/test.log.1", "/root/stap/test.log.2") = 0 rename("/root/stap/test.log.0", "/root/stap/test.log.1") = -1 ENOENT (No such file or directory) access("/root/stap/test.log.5", F_OK) = -1 ENOENT (No such file or directory) open("/root/stap/test.log", O_RDWR|O_LARGEFILE) = 3 open("/root/stap/test.log.1", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0100644) = 4 fchmod(4, 0600) = 0 fchown32(4, 0, 0) = 0 fchmod(4, 0100644) = 0 read(3, "1308784634\n1308784635\n1308784636"..., 8192) = 319 write(4, "1308784634\n1308784635\n1308784636"..., 319) = 319 read(3, "", 8192) = 0 ftruncate64(3, 0) = 0 close(3) = 0 close(4) = 0