「Logrotate」の版間の差分
提供: Wikinote
(→動作) |
|||
行10: | 行10: | ||
== 動作 == | == 動作 == | ||
+ | |||
+ | === compress === | ||
+ | |||
+ | rotate 4 | ||
+ | compress | ||
+ | |||
+ | # 古いログから順に rename | ||
+ | # log.1 と log.1.gz を open し、gzip 経由で log.1.gz へ write | ||
+ | # log.1 を unlink | ||
+ | |||
+ | 13534 rename("/tmp/test.log.4.gz", "/tmp/test.log.5.gz") = -1 ENOENT (No such file or directory) | ||
+ | 13534 rename("/tmp/test.log.3.gz", "/tmp/test.log.4.gz") = -1 ENOENT (No such file or directory) | ||
+ | 13534 rename("/tmp/test.log.2.gz", "/tmp/test.log.3.gz") = -1 ENOENT (No such file or directory) | ||
+ | 13534 rename("/tmp/test.log.1.gz", "/tmp/test.log.2.gz") = 0 | ||
+ | 13534 rename("/tmp/test.log.0.gz", "/tmp/test.log.1.gz") = -1 ENOENT (No such file or directory) | ||
+ | 13534 access("/tmp/test.log.5.gz", F_OK) = -1 ENOENT (No such file or directory) | ||
+ | 13534 rename("/tmp/test.log", "/tmp/test.log.1") = 0 | ||
+ | 13534 open("/tmp/test.log.1", O_RDONLY|O_LARGEFILE) = 3 | ||
+ | 13534 open("/tmp/test.log.1.gz", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0100644) = 4 | ||
+ | 13534 fchmod(4, 0600) = 0 | ||
+ | 13534 fchown32(4, 500, 500) = 0 | ||
+ | 13534 fchmod(4, 0100644) = 0 | ||
+ | 13534 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7fa7718) = 13535 | ||
+ | ... | ||
+ | 13535 execve("/bin/gzip", ["/bin/gzip"], [/* 31 vars */]) = 0 | ||
+ | ... | ||
+ | 13535 read(0, "2011\345\271\264 6\346\234\210 24\346\227\245 \351\207\221\346\233\234\346\227\245 00"..., 65536) = 258 | ||
+ | 13535 read(0, "", 65278) = 0 | ||
+ | 13535 write(1, "\37\213\10\0fb\3N\0\0033204|\272s\213\202\202\331\2639\35\nF&\317\246/Ux"..., 82) = 82 | ||
+ | ... | ||
+ | 13534 --- SIGCHLD (Child exited) @ 0 (0) --- | ||
+ | 13534 unlink("/tmp/test.log.1") = 0 | ||
+ | |||
=== copytruncate === | === copytruncate === | ||
− | |||
rotate 4 | rotate 4 | ||
copytruncate | copytruncate | ||
− | + | # 古いログから順に rename | |
− | open | + | # log と log.1 を open し、log から読んで log.1 へ write |
+ | # log を ftruncate | ||
rename("/root/stap/test.log.4", "/root/stap/test.log.5") = -1 ENOENT (No such file or directory) | rename("/root/stap/test.log.4", "/root/stap/test.log.5") = -1 ENOENT (No such file or directory) | ||
行38: | 行71: | ||
=== nocopytruncate === | === nocopytruncate === | ||
− | + | ||
+ | rotate 4 | ||
+ | nocopytruncate | ||
+ | |||
+ | デフォルトの動作。単に古いログから順に rename するだけ。 | ||
+ | |||
rename("/root/stap/test.log.4", "/root/stap/test.log.5") = -1 ENOENT (No such file or directory) | 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.3", "/root/stap/test.log.4") = -1 ENOENT (No such file or directory) |
2011年6月24日 (金) 01:07時点における版
設定
デフォルト
logrotate-3.7.4-8 (CentOS 5.2) の /etc/logrotate.conf の内容は以下。
weekly rotate 4 create #compress include /etc/logrotate.d
動作
compress
rotate 4 compress
- 古いログから順に rename
- log.1 と log.1.gz を open し、gzip 経由で log.1.gz へ write
- log.1 を unlink
13534 rename("/tmp/test.log.4.gz", "/tmp/test.log.5.gz") = -1 ENOENT (No such file or directory) 13534 rename("/tmp/test.log.3.gz", "/tmp/test.log.4.gz") = -1 ENOENT (No such file or directory) 13534 rename("/tmp/test.log.2.gz", "/tmp/test.log.3.gz") = -1 ENOENT (No such file or directory) 13534 rename("/tmp/test.log.1.gz", "/tmp/test.log.2.gz") = 0 13534 rename("/tmp/test.log.0.gz", "/tmp/test.log.1.gz") = -1 ENOENT (No such file or directory) 13534 access("/tmp/test.log.5.gz", F_OK) = -1 ENOENT (No such file or directory) 13534 rename("/tmp/test.log", "/tmp/test.log.1") = 0 13534 open("/tmp/test.log.1", O_RDONLY|O_LARGEFILE) = 3 13534 open("/tmp/test.log.1.gz", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0100644) = 4 13534 fchmod(4, 0600) = 0 13534 fchown32(4, 500, 500) = 0 13534 fchmod(4, 0100644) = 0 13534 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7fa7718) = 13535 ... 13535 execve("/bin/gzip", ["/bin/gzip"], [/* 31 vars */]) = 0 ... 13535 read(0, "2011\345\271\264 6\346\234\210 24\346\227\245 \351\207\221\346\233\234\346\227\245 00"..., 65536) = 258 13535 read(0, "", 65278) = 0 13535 write(1, "\37\213\10\0fb\3N\0\0033204|\272s\213\202\202\331\2639\35\nF&\317\246/Ux"..., 82) = 82 ... 13534 --- SIGCHLD (Child exited) @ 0 (0) --- 13534 unlink("/tmp/test.log.1") = 0
copytruncate
rotate 4 copytruncate
- 古いログから順に rename
- log と log.1 を open し、log から読んで log.1 へ write
- log を 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
nocopytruncate
rotate 4 nocopytruncate
デフォルトの動作。単に古いログから順に rename するだけ。
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") = 0 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) rename("/root/stap/test.log", "/root/stap/test.log.1") = 0