version 1, including all changes.
.
| Rev |
Author |
# |
Line |
| 1 |
perry |
1 |
LOGROTATE |
| |
|
2 |
!!!LOGROTATE |
| |
|
3 |
NAME |
| |
|
4 |
SYNOPSIS |
| |
|
5 |
DESCRIPTION |
| |
|
6 |
OPTIONS |
| |
|
7 |
CONFIGURATION FILE |
| |
|
8 |
FILES |
| |
|
9 |
SEE ALSO |
| |
|
10 |
NOTES |
| |
|
11 |
AUTHORS |
| |
|
12 |
---- |
| |
|
13 |
!!NAME |
| |
|
14 |
|
| |
|
15 |
|
| |
|
16 |
logrotate - rotates, compresses, and mails system logs |
| |
|
17 |
!!SYNOPSIS |
| |
|
18 |
|
| |
|
19 |
|
| |
|
20 |
__logrotate__ [[__-dv__] [[__-f__|__--force__] |
| |
|
21 |
[[__-s__|__--state__ ''statefile''] |
| |
|
22 |
''config_file'' .. |
| |
|
23 |
!!DESCRIPTION |
| |
|
24 |
|
| |
|
25 |
|
| |
|
26 |
__logrotate__ is designed to ease administration of |
| |
|
27 |
systems that generate large numbers of log files. It allows |
| |
|
28 |
automatic rotation, compression, removal, and mailing of log |
| |
|
29 |
files. Each log file may be handled daily, weekly, monthly, |
| |
|
30 |
or when it grows too large. |
| |
|
31 |
|
| |
|
32 |
|
| |
|
33 |
Normally, __logrotate__ is run as a daily cron job. It |
| |
|
34 |
will not modify a log more than once in one day unless the |
| |
|
35 |
criterion for that log is based on the log's size and |
| |
|
36 |
__logrotate__ is being run more than once each day, or |
| |
|
37 |
unless the __-f__ or __--force__ option is |
| |
|
38 |
used. |
| |
|
39 |
|
| |
|
40 |
|
| |
|
41 |
Any number of config files may be given on the command line. |
| |
|
42 |
Later config files may override the options given in earlier |
| |
|
43 |
files, so the order in which the __logrotate__ config |
| |
|
44 |
files are listed is important. Normally, a single config |
| |
|
45 |
file which includes any other config files which are needed |
| |
|
46 |
should be used. See below for more information on how to use |
| |
|
47 |
the __include__ directive to accomplish this. If a |
| |
|
48 |
directory is given on the command line, every file in that |
| |
|
49 |
directory is used as a config file. |
| |
|
50 |
|
| |
|
51 |
|
| |
|
52 |
If no command line arguments are given, __logrotate__ |
| |
|
53 |
will print version and copyright information, along with a |
| |
|
54 |
short usage summary. If any errors occur while rotating |
| |
|
55 |
logs, __logrotate__ will exit with non-zero |
| |
|
56 |
status. |
| |
|
57 |
!!OPTIONS |
| |
|
58 |
|
| |
|
59 |
|
| |
|
60 |
__-d__ |
| |
|
61 |
|
| |
|
62 |
|
| |
|
63 |
Turns on debug mode and implies __-v__. In debug mode, no |
| |
|
64 |
changes will be made to the logs or to the __logrotate__ |
| |
|
65 |
state file. |
| |
|
66 |
|
| |
|
67 |
|
| |
|
68 |
__-f__, __--force__ |
| |
|
69 |
|
| |
|
70 |
|
| |
|
71 |
Tells __logrotate__ to force the rotation, even if it |
| |
|
72 |
doesn't think this is necessary. Sometimes this is useful |
| |
|
73 |
after adding new entries to a __logrotate__ config file, |
| |
|
74 |
or if old log files have been removed by hand, as the new |
| |
|
75 |
files will be created, and logging will continue |
| |
|
76 |
correctly. |
| |
|
77 |
|
| |
|
78 |
|
| |
|
79 |
__-s__, __--state__ ''statefile'' |
| |
|
80 |
|
| |
|
81 |
|
| |
|
82 |
Tells __logrotate__ to use an alternate state file. This |
| |
|
83 |
is useful if __logrotate__ is being run as different |
| |
|
84 |
users for various sets of log files. The default state file |
| |
|
85 |
is ''/var/lib/logrotate/status''. |
| |
|
86 |
|
| |
|
87 |
|
| |
|
88 |
__--usage__ |
| |
|
89 |
|
| |
|
90 |
|
| |
|
91 |
Prints a short usage message. |
| |
|
92 |
|
| |
|
93 |
|
| |
|
94 |
__-v__, __--verbose__ |
| |
|
95 |
|
| |
|
96 |
|
| |
|
97 |
Display messages during rotation. |
| |
|
98 |
!!CONFIGURATION FILE |
| |
|
99 |
|
| |
|
100 |
|
| |
|
101 |
__logrotate__ reads everything about the log files it |
| |
|
102 |
should be handling from the series of configuration files |
| |
|
103 |
specified on the command line. Each configuration file can |
| |
|
104 |
set global options (local definitions override global ones, |
| |
|
105 |
and later definitions override earlier ones) and specify |
| |
|
106 |
some logfiles to rotate. A simple configuration file looks |
| |
|
107 |
like this: |
| |
|
108 |
|
| |
|
109 |
|
| |
|
110 |
# sample logrotate configuration file |
| |
|
111 |
compress |
| |
|
112 |
/var/log/messages { |
| |
|
113 |
rotate 5 |
| |
|
114 |
weekly |
| |
|
115 |
postrotate |
| |
|
116 |
/sbin/killall -HUP syslogd |
| |
|
117 |
endscript |
| |
|
118 |
} |
| |
|
119 |
The first few lines set global options; in the example, logs are compressed after they are rotated. Note that comments may appear anywhere in the config file as long as the first non-whitespace character on the line is a __#__. |
| |
|
120 |
|
| |
|
121 |
|
| |
|
122 |
The next section of the config file defines how to handle |
| |
|
123 |
the log file ''/var/log/messages''. The log will go |
| |
|
124 |
through five weekly rotations before being removed. After |
| |
|
125 |
the log file has been rotated (but before the old version of |
| |
|
126 |
the log has been compressed), the command ''/sbin/killall |
| |
|
127 |
-HUP syslogd'' will be executed. |
| |
|
128 |
|
| |
|
129 |
|
| |
|
130 |
The next section defines the parameters for both |
| |
|
131 |
''/var/log/httpd/access.log'' and |
| |
|
132 |
''/var/log/httpd/error.log''. Each is rotated whenever it |
| |
|
133 |
grows over 100k in size, and the old logs files are mailed |
| |
|
134 |
(uncompressed) to www@my.org after going through 5 |
| |
|
135 |
rotations, rather then being removed. The |
| |
|
136 |
__sharedscripts__ means that the __postrotate__ script |
| |
|
137 |
will only be run once, not once for each log which is |
| |
|
138 |
rotated. Note that log file names may be enclosed in quotes |
| |
|
139 |
(and that quotes are required if the name contains spaces). |
| |
|
140 |
Normal shell quoting rules apply, with __'__, |
| |
|
141 |
____, and __\__ characters |
| |
|
142 |
supported. |
| |
|
143 |
|
| |
|
144 |
|
| |
|
145 |
The last section defines the parameters for all of the files |
| |
|
146 |
in ''/var/log/news''. Each file is rotated on a monthly |
| |
|
147 |
basis. This is considered a single rotation directive and if |
| |
|
148 |
errors occur for more then one file, the log files are not |
| |
|
149 |
compressed. |
| |
|
150 |
|
| |
|
151 |
|
| |
|
152 |
If the directory ''/var/log/news'' does not exist, this |
| |
|
153 |
will cause __logrotate__ to report an error. This error |
| |
|
154 |
cannot be stopped with the __missingok__ |
| |
|
155 |
directive. |
| |
|
156 |
|
| |
|
157 |
|
| |
|
158 |
Here is more information on the directives which may be |
| |
|
159 |
included in a __logrotate__ configuration |
| |
|
160 |
file: |
| |
|
161 |
|
| |
|
162 |
|
| |
|
163 |
__compress__ |
| |
|
164 |
|
| |
|
165 |
|
| |
|
166 |
Old versions of log files are compressed with gzip(1) |
| |
|
167 |
by default. See also __nocompress__. |
| |
|
168 |
|
| |
|
169 |
|
| |
|
170 |
__compresscmd__ |
| |
|
171 |
|
| |
|
172 |
|
| |
|
173 |
Specifies which command to use to compress log files. The |
| |
|
174 |
default is gzip(1). See also |
| |
|
175 |
__compress__. |
| |
|
176 |
|
| |
|
177 |
|
| |
|
178 |
__uncompresscmd__ |
| |
|
179 |
|
| |
|
180 |
|
| |
|
181 |
Specifies which command to use to uncompress log files. The |
| |
|
182 |
default is gunzip(1). |
| |
|
183 |
|
| |
|
184 |
|
| |
|
185 |
__compressext__ |
| |
|
186 |
|
| |
|
187 |
|
| |
|
188 |
Specifies which extension to use on compressed logfiles, if |
| |
|
189 |
compression is enabled. The default follows that of the |
| |
|
190 |
configured compression command. |
| |
|
191 |
|
| |
|
192 |
|
| |
|
193 |
__compressoptions__ |
| |
|
194 |
|
| |
|
195 |
|
| |
|
196 |
Command line options may be passed to the compression |
| |
|
197 |
program, if one is in use. The default, for __gzip__, is |
| |
|
198 |
__ |
| |
|
199 |
|
| |
|
200 |
|
| |
|
201 |
__copytruncate__ |
| |
|
202 |
|
| |
|
203 |
|
| |
|
204 |
Truncate the original log file to zero size in place after |
| |
|
205 |
creating a copy, instead of moving the old log file and |
| |
|
206 |
optionally creating a new one. It can be used when some |
| |
|
207 |
program cannot be told to close its logfile and thus might |
| |
|
208 |
continue writing (appending) to the previous log file |
| |
|
209 |
forever. Note that there is a very small time slice between |
| |
|
210 |
copying the file and truncating it, so some logging data |
| |
|
211 |
might be lost. When this option is used, the __create__ |
| |
|
212 |
option will have no effect, as the old log file stays in |
| |
|
213 |
place. |
| |
|
214 |
|
| |
|
215 |
|
| |
|
216 |
__create__ ''mode owner group'' |
| |
|
217 |
|
| |
|
218 |
|
| |
|
219 |
Immediately after rotation (before the __postrotate__ |
| |
|
220 |
script is run) the log file is created (with the same name |
| |
|
221 |
as the log file just rotated). ''mode'' specifies the |
| |
|
222 |
mode for the log file in octal (the same as |
| |
|
223 |
chmod(2)), ''owner'' specifies the user name who |
| |
|
224 |
will own the log file, and ''group'' specifies the group |
| |
|
225 |
the log file will belong to. Any of the log file attributes |
| |
|
226 |
may be omitted, in which case those attributes for the new |
| |
|
227 |
file will use the same values as the original log file for |
| |
|
228 |
the omitted attributes. This option can be disabled using |
| |
|
229 |
the __nocreate__ option. |
| |
|
230 |
|
| |
|
231 |
|
| |
|
232 |
__daily__ |
| |
|
233 |
|
| |
|
234 |
|
| |
|
235 |
Log files are rotated every day. |
| |
|
236 |
|
| |
|
237 |
|
| |
|
238 |
__delaycompress__ |
| |
|
239 |
|
| |
|
240 |
|
| |
|
241 |
Postpone compression of the previous log file to the next |
| |
|
242 |
rotation cycle. This only has effect when used in |
| |
|
243 |
combination with __compress__. It can be used when some |
| |
|
244 |
program cannot be told to close its logfile and thus might |
| |
|
245 |
continue writing to the previous log file for some |
| |
|
246 |
time. |
| |
|
247 |
|
| |
|
248 |
|
| |
|
249 |
__extension__ ''ext'' |
| |
|
250 |
|
| |
|
251 |
|
| |
|
252 |
Log files are given the final extension ''ext'' after |
| |
|
253 |
rotation. If compression is used, the compression extension |
| |
|
254 |
(normally ''.gz'') appears after ''ext''. |
| |
|
255 |
|
| |
|
256 |
|
| |
|
257 |
__ifempty__ |
| |
|
258 |
|
| |
|
259 |
|
| |
|
260 |
Rotate the log file even if it is empty, overriding the |
| |
|
261 |
__notifempty__ option (__ifempty__ is the |
| |
|
262 |
default). |
| |
|
263 |
|
| |
|
264 |
|
| |
|
265 |
__include__ ''file_or_directory'' |
| |
|
266 |
|
| |
|
267 |
|
| |
|
268 |
Reads the file given as an argument as if it was included |
| |
|
269 |
inline where the __include__ directive appears. If a |
| |
|
270 |
directory is given, most of the files in that directory are |
| |
|
271 |
read before processing of the including file continues. The |
| |
|
272 |
only files which are ignored are files which are not regular |
| |
|
273 |
files (such as directories and named pipes) and files whose |
| |
|
274 |
names end with one of the taboo extensions, as specified by |
| |
|
275 |
the __tabooext__ directive. The __include__ directive |
| |
|
276 |
may not appear inside a log file definition. |
| |
|
277 |
|
| |
|
278 |
|
| |
|
279 |
__mail__ ''address'' |
| |
|
280 |
|
| |
|
281 |
|
| |
|
282 |
When a log is rotated out of existence, it is mailed to |
| |
|
283 |
''address''. If no mail should be generated by a |
| |
|
284 |
particular log, the __nomail__ directive may be |
| |
|
285 |
used. |
| |
|
286 |
|
| |
|
287 |
|
| |
|
288 |
__mailfirst__ |
| |
|
289 |
|
| |
|
290 |
|
| |
|
291 |
When using the __mail__ command, mail the just-rotated |
| |
|
292 |
file, instead of the about-to-expire file. |
| |
|
293 |
|
| |
|
294 |
|
| |
|
295 |
__maillast__ |
| |
|
296 |
|
| |
|
297 |
|
| |
|
298 |
When using the __mail__ command, mail the about-to-expire |
| |
|
299 |
file, instead of the just-rotated file (this is the |
| |
|
300 |
default). |
| |
|
301 |
|
| |
|
302 |
|
| |
|
303 |
__missingok__ |
| |
|
304 |
|
| |
|
305 |
|
| |
|
306 |
If the log file is missing, go on to the next one without |
| |
|
307 |
issuing an error message. See also |
| |
|
308 |
__nomissingok__. |
| |
|
309 |
|
| |
|
310 |
|
| |
|
311 |
__monthly__ |
| |
|
312 |
|
| |
|
313 |
|
| |
|
314 |
Log files are rotated the first time __logrotate__ is run |
| |
|
315 |
in a month (this is normally on the first day of the |
| |
|
316 |
month). |
| |
|
317 |
|
| |
|
318 |
|
| |
|
319 |
__nocompress__ |
| |
|
320 |
|
| |
|
321 |
|
| |
|
322 |
Old versions of log files are not compressed. See also |
| |
|
323 |
__compress__. |
| |
|
324 |
|
| |
|
325 |
|
| |
|
326 |
__nocopytruncate__ |
| |
|
327 |
|
| |
|
328 |
|
| |
|
329 |
Do not truncate the original log file in place after |
| |
|
330 |
creating a copy (this overrides the __copytruncate__ |
| |
|
331 |
option). |
| |
|
332 |
|
| |
|
333 |
|
| |
|
334 |
__nocreate__ |
| |
|
335 |
|
| |
|
336 |
|
| |
|
337 |
New log files are not created (this overrides the |
| |
|
338 |
__create__ option). |
| |
|
339 |
|
| |
|
340 |
|
| |
|
341 |
__nodelaycompress__ |
| |
|
342 |
|
| |
|
343 |
|
| |
|
344 |
Do not postpone compression of the previous log file to the |
| |
|
345 |
next rotation cycle (this overrides the __delaycompress__ |
| |
|
346 |
option). |
| |
|
347 |
|
| |
|
348 |
|
| |
|
349 |
__nomail__ |
| |
|
350 |
|
| |
|
351 |
|
| |
|
352 |
Do not mail old log files to any address. |
| |
|
353 |
|
| |
|
354 |
|
| |
|
355 |
__nomissingok__ |
| |
|
356 |
|
| |
|
357 |
|
| |
|
358 |
If a log file does not exist, issue an error. This is the |
| |
|
359 |
default. |
| |
|
360 |
|
| |
|
361 |
|
| |
|
362 |
__noolddir__ |
| |
|
363 |
|
| |
|
364 |
|
| |
|
365 |
Logs are rotated in the directory they normally reside in |
| |
|
366 |
(this overrides the __olddir__ option). |
| |
|
367 |
|
| |
|
368 |
|
| |
|
369 |
__nosharedscripts__ |
| |
|
370 |
|
| |
|
371 |
|
| |
|
372 |
Run __prerotate__ and __postrotate__ scripts for every |
| |
|
373 |
log that is rotated (this is the default, and overrides the |
| |
|
374 |
__sharedscripts__ option). |
| |
|
375 |
|
| |
|
376 |
|
| |
|
377 |
__notifempty__ |
| |
|
378 |
|
| |
|
379 |
|
| |
|
380 |
Do not rotate the log if it is empty (this overrides the |
| |
|
381 |
__ifempty__ option). |
| |
|
382 |
|
| |
|
383 |
|
| |
|
384 |
__olddir__ ''directory'' |
| |
|
385 |
|
| |
|
386 |
|
| |
|
387 |
Logs are moved into ''directory'' for rotation. The |
| |
|
388 |
''directory'' must be on the same physical device as the |
| |
|
389 |
log file being rotated. When this option is used all old |
| |
|
390 |
versions of the log end up in ''directory''. This option |
| |
|
391 |
may be overridden by the __noolddir__ |
| |
|
392 |
option. |
| |
|
393 |
|
| |
|
394 |
|
| |
|
395 |
__postrotate__/__endscript__ |
| |
|
396 |
|
| |
|
397 |
|
| |
|
398 |
The lines between __postrotate__ and __endscript__ |
| |
|
399 |
(both of which must appear on lines by themselves) are |
| |
|
400 |
executed after the log file is rotated. These directives may |
| |
|
401 |
only appear inside a log file definition. See also |
| |
|
402 |
__prerotate__. |
| |
|
403 |
|
| |
|
404 |
|
| |
|
405 |
__prerotate__/__endscript__ |
| |
|
406 |
|
| |
|
407 |
|
| |
|
408 |
The lines between __prerotate__ and __endscript__ |
| |
|
409 |
(both of which must appear on lines by themselves) are |
| |
|
410 |
executed before the log file is rotated. These directives |
| |
|
411 |
may only appear inside a log file definition. See also |
| |
|
412 |
__postrotate__. |
| |
|
413 |
|
| |
|
414 |
|
| |
|
415 |
__rotate__ ''count'' |
| |
|
416 |
|
| |
|
417 |
|
| |
|
418 |
Log files are rotated ''count'' times before being |
| |
|
419 |
removed or mailed to the address specified in a __mail__ |
| |
|
420 |
directive. If ''count'' is 0, old versions are removed |
| |
|
421 |
rather then rotated. |
| |
|
422 |
|
| |
|
423 |
|
| |
|
424 |
__sharedscripts__ |
| |
|
425 |
|
| |
|
426 |
|
| |
|
427 |
Normally, __prerotate__ and __postrotate__ scripts are |
| |
|
428 |
run for each log which is rotated, meaning that a single |
| |
|
429 |
script may be run multiple times for log file entries which |
| |
|
430 |
match multiple files (such as the ''/var/log/news/*'' |
| |
|
431 |
example). If __sharedscript__ is specified, the scripts |
| |
|
432 |
are only run once, no matter how many logs match the |
| |
|
433 |
wildcarded pattern. A side effect of this option is that the |
| |
|
434 |
scripts are always executed, even if no logs are rotated. If |
| |
|
435 |
this directive is not specified, the scripts are run only if |
| |
|
436 |
logs are actually rotated. This overrides the |
| |
|
437 |
__nosharedscripts__ option. |
| |
|
438 |
|
| |
|
439 |
|
| |
|
440 |
__size__ ''size''[[__M__|__k__] |
| |
|
441 |
|
| |
|
442 |
|
| |
|
443 |
Log files are rotated when they grow bigger than ''size'' |
| |
|
444 |
bytes. If ''size'' is followed by __M__, the size is |
| |
|
445 |
assumed to be in megabytes. If __k__ is used, the size is |
| |
|
446 |
in kilobytes. So __size 100__, __size 100k__, and |
| |
|
447 |
__size 100M__ are all valid. |
| |
|
448 |
|
| |
|
449 |
|
| |
|
450 |
__tabooext__ [[__+__] ''list'' |
| |
|
451 |
|
| |
|
452 |
|
| |
|
453 |
The current taboo extension list is changed (see the |
| |
|
454 |
__include__ directive for information on the taboo |
| |
|
455 |
extensions). If __+__ precedes ''list'', the current |
| |
|
456 |
taboo extension list is augmented by ''list'', otherwise |
| |
|
457 |
it is replaced. At startup, the taboo extension list |
| |
|
458 |
contains .rpmorig, .rpmsave, .dpkg-dist, .dpkg-old, |
| |
|
459 |
.dpkg-new, .disabled, ,v, .swp, .rpmnew, and ~. The members |
| |
|
460 |
of the list are separated by spaces, not |
| |
|
461 |
commas. |
| |
|
462 |
|
| |
|
463 |
|
| |
|
464 |
__weekly__ |
| |
|
465 |
|
| |
|
466 |
|
| |
|
467 |
Log files are rotated if the current weekday is less than |
| |
|
468 |
the weekday of the last rotation or if more than a week has |
| |
|
469 |
passed since the last rotation. This is normally the same as |
| |
|
470 |
rotating logs on the first day of the week, but works better |
| |
|
471 |
if __logrotate__ is not run every night. |
| |
|
472 |
!!FILES |
| |
|
473 |
|
| |
|
474 |
|
| |
|
475 |
''/var/lib/logrotate/status'' |
| |
|
476 |
|
| |
|
477 |
|
| |
|
478 |
Default state file. |
| |
|
479 |
|
| |
|
480 |
|
| |
|
481 |
''/etc/logrotate.conf'' Configuration |
| |
|
482 |
options. |
| |
|
483 |
!!SEE ALSO |
| |
|
484 |
|
| |
|
485 |
|
| |
|
486 |
gzip(1) |
| |
|
487 |
!!NOTES |
| |
|
488 |
|
| |
|
489 |
|
| |
|
490 |
The killall(1) program in Debian is found in the |
| |
|
491 |
''psmisc'' package. |
| |
|
492 |
!!AUTHORS |
| |
|
493 |
|
| |
|
494 |
|
| |
|
495 |
Erik Troan |
| |
|
496 |
---- |