12
11
weekly, monthly, or when it grows too large.
14
13
Normally, \fBlogrotate\fR is run as a daily cron job. It will not modify
15
a log more than once in one day unless the criterion for that log is
16
based on the log's size and \fBlogrotate\fR is being run more than once
17
each day, or unless the \fB-f\fR or \fB-\-force\fR option is used.
14
a log multiple times in one day unless the criterium for that log is
15
based on the log's size and \fBlogrotate\fR is being run multiple times
16
each day, or unless the \fB-f\fR or \fB-force\fR option is used.
19
18
Any number of config files may be given on the command line. Later config
20
19
files may override the options given in earlier files, so the order
21
in which the \fBlogrotate\fR config files are listed is important.
20
in which the \fBlogrotate\fR config files are listed in is important.
22
21
Normally, a single config file which includes any other config files
23
22
which are needed should be used. See below for more information on how
24
to use the \fBinclude\fR directive to accomplish this. If a directory
23
to use the \fIinclude\fR directive to accomplish this. If a directory
25
24
is given on the command line, every file in that directory is used as
37
36
be made to the logs or to the \fBlogrotate\fR state file.
40
\fB-f\fR, \fB-\-force\fR
41
40
Tells \fBlogrotate\fR to force the rotation, even if it doesn't think
42
41
this is necessary. Sometimes this is useful after adding new entries to
43
a \fBlogrotate\fR config file, or if old log files have been removed
44
by hand, as the new files will be created, and logging will continue
48
\fB-s\fR, \fB-\-state\fR \fIstatefile\fR
42
\fBlogrotate\fR, or if old log files have been removed by hand, as the
43
new files will be created, and logging will continue correctly.
46
\fB-m, -\-mail <command>\fR
47
Tells \fBlogrotate\fR which command to use when mailing logs. This
48
command should accept two arguments: 1) the subject of the message, and
49
2) the recipient. The command must then read a message on standard input
50
and mail it to the recipient. The default mail command is \fB/bin/mail
54
\fB-s, -\-state <statefile>\fR
49
55
Tells \fBlogrotate\fR to use an alternate state file. This is useful
50
if \fBlogrotate\fR is being run as different users for various sets of
56
if logrotate is being run as a different user for various sets of
51
57
log files. The default state file is \fI/var/lib/logrotate/status\fR.
55
61
Prints a short usage message.
58
\fB-v\fR, \fB--verbose\fR
59
Display messages during rotation.
62
63
.SH CONFIGURATION FILE
64
65
\fBlogrotate\fR reads everything about the log files it should be handling
65
66
from the series of configuration files specified on the command line. Each
66
67
configuration file can set global options (local definitions override
67
68
global ones, and later definitions override earlier ones) and specify
68
some logfiles to rotate. A simple configuration file looks like this:
69
a logfile to rotate. A simple configuration file looks like this:
163
165
in use. The default, for \fBgzip\fR, is "-9" (maximum compression).
169
Make a copy of the log file, but don't change the original at all.
170
This option can be used, for instance, to make a snapshot of the current
171
log file, or when some other utility needs to truncate or pare the file.
172
When this option is used, the \fBcreate\fR option will have no effect,
173
as the old log file stays in place.
166
176
\fBcopytruncate\fR
167
Truncate the original log file to zero size in place after creating a copy,
168
instead of moving the old log file and optionally creating a new one.
169
It can be used when some program cannot be told to close its logfile
177
Truncate the original log file in place after creating a copy,
178
instead of moving the old log file and optionally creating a new one,
179
It can be used when some program can not be told to close its logfile
170
180
and thus might continue writing (appending) to the previous log file forever.
171
181
Note that there is a very small time slice between copying the file and
172
182
truncating it, so some logging data might be lost.
193
203
\fBdelaycompress\fR
194
204
Postpone compression of the previous log file to the next rotation cycle.
195
This only has effect when used in combination with \fBcompress\fR.
196
It can be used when some program cannot be told to close its logfile
205
This has only effect when used in combination with \fBcompress\fR.
206
It can be used when some program can not be told to close its logfile
197
207
and thus might continue writing to the previous log file for some time.
200
210
\fBextension \fIext\fR
201
211
Log files are given the final extension \fIext\fR after rotation. If
202
compression is used, the compression extension (normally \fI.gz\fR)
212
compression is used, the compression extension (normally \fB.gz\fR)
203
213
appears after \fIext\fR.
207
Rotate the log file even if it is empty, overriding the \fBnotifempty\fR
208
option (\fBifempty\fR is the default).
217
Rotate the log file even if it is empty, overiding the \fBnotifempty\fR
218
option (ifempty is the default).
211
221
\fBinclude \fIfile_or_directory\fR
212
Reads the file given as an argument as if it was included inline where
213
the \fBinclude\fR directive appears. If a directory is given, most of the
214
files in that directory are read before processing of the including file
215
continues. The only files which are ignored are files which are not regular
216
files (such as directories and named pipes) and files whose names end
217
with one of the taboo extensions, as specified by the \fBtabooext\fR
218
directive. The \fBinclude\fR directive may not appear inside a log
222
Reads the file given as an argument as if it was included inline
223
where the \fBinclude\fR directive appears. If a directory is given,
224
most of the files in that directory are read in alphabetic order
225
before processing of the including file continues. The only files
226
which are ignored are files which are not regular files (such as
227
directories and named pipes) and files whose names end with one of
228
the taboo extensions, as specified by the \fBtabooext\fR directive.
229
The \fBinclude\fR directive may not appear inside of a log file
222
233
\fBmail \fIaddress\fR
223
When a log is rotated out of existence, it is mailed to \fIaddress\fR. If
234
When a log is rotated out-of-existence, it is mailed to \fIaddress\fR. If
224
235
no mail should be generated by a particular log, the \fBnomail\fR directive
289
306
\fBolddir \fIdirectory\fR
290
Logs are moved into \fIdirectory\fR for rotation. The \fIdirectory\fR must
291
be on the same physical device as the log file being rotated. When this
292
option is used all old versions of the log end up in \fIdirectory\fR. This
293
option may be overridden by the \fBnoolddir\fR option.
307
Logs are moved into \fIdirectory\fR for rotation. The \fIdirectory\fR
308
must be on the same physical device as the log file being rotated,
309
and is assumed to be relative to the directory holding the log file
310
unless an absolute path name is specified. When this option is used all
311
old versions of the log end up in \fIdirectory\fR. This option may be
312
overriden by the \fBnoolddir\fR option.
296
315
\fBpostrotate\fR/\fBendscript\fR
297
316
The lines between \fBpostrotate\fR and \fBendscript\fR (both of which
298
317
must appear on lines by themselves) are executed after the log file is
299
rotated. These directives may only appear inside a log file definition.
300
See also \fBprerotate\fR.
318
rotated. These directives may only appear inside of a log file definition.
319
See \fBprerotate\fR as well.
303
322
\fBprerotate\fR/\fBendscript\fR
304
323
The lines between \fBprerotate\fR and \fBendscript\fR (both of which
305
324
must appear on lines by themselves) are executed before the log file is
306
rotated. These directives may only appear inside a log file definition.
307
See also \fBpostrotate\fR.
325
rotated and only if the log will actually be rotated. These directives
326
may only appear inside of a log file definition. See \fBpostrotate\fR
330
\fBfirstaction\fR/\fBendscript\fR
331
The lines between \fBfirstaction\fR and \fBendscript\fR (both of which
332
must appear on lines by themselves) are executed once before all log
333
files that match the wildcarded pattern are rotated, before prerotate script
334
is run and only if at least one log will actually be rotated. These directives
335
may only appear inside of a log file definition. See \fBlastaction\fR as well.
338
\fBlastaction\fR/\fBendscript\fR
339
The lines between \fBlastaction\fR and \fBendscript\fR (both of which
340
must appear on lines by themselves) are executed once after all log
341
files that match the wildcarded pattern are rotated, after postrotate script
342
is run and only if at least one log is rotated. These directives may only
343
appear inside of a log file definition. See \fBlastaction\fR as well.
310
346
\fBrotate \fIcount\fR
311
Log files are rotated \fIcount\fR times before being removed or mailed to the
347
Log files are rotated <count> times before being removed or mailed to the
312
348
address specified in a \fBmail\fR directive. If \fIcount\fR is 0, old versions
313
349
are removed rather then rotated.
353
Log files are rotated when they grow bigger then \fIsize\fR bytes. If
354
\fIsize\fR is followed by \fIM\fR, the size if assumed to be in megabytes.
355
If the \fIk\fR is used, the size is in kilobytes. So \fBsize 100\fR,
356
\fIsize 100k\fR, and \fIsize 100M\fR are all valid.
316
359
\fBsharedscripts\fR
317
Normally, \fBprerotate\fR and \fBpostrotate\fR scripts are run for each
360
Normally, \fBprescript\fR and \fBpostscript\fR scripts are run for each
318
361
log which is rotated, meaning that a single script may be run multiple
319
362
times for log file entries which match multiple files (such as the
320
\fI/var/log/news/*\fR example). If \fBsharedscript\fR is specified, the scripts
363
/var/log/news/* example). If \fBsharedscript\fR is specified, the scripts
321
364
are only run once, no matter how many logs match the wildcarded pattern.
322
A side effect of this option is that the scripts are always executed, even
323
if no logs are rotated. If this directive is not specified, the scripts
324
are run only if logs are actually rotated. This overrides the
325
\fBnosharedscripts\fR option.
328
\fBsize \fIsize\fR[\fBM\fR|\fBk\fR]
329
Log files are rotated when they grow bigger than \fIsize\fR bytes. If
330
\fIsize\fR is followed by \fBM\fR, the size is assumed to be in megabytes.
331
If \fBk\fR is used, the size is in kilobytes. So \fBsize 100\fR,
332
\fBsize 100k\fR, and \fBsize 100M\fR are all valid.
335
\fBtabooext\fR [\fB+\fR] \fIlist\fR
365
However, if none of the logs in the pattern require rotating, the scripts
366
will not be run at all. This option overrides the \fbnosharedscripts\fR
371
This is the number to use as the base for rotation. For example, if
372
you specify 0, the logs will be created with a .0 extension as they are
373
rotated from the original log files. If you specify 9, log files will
374
be created with a .9, skipping 0-8. Files will still be rotated the
375
number of times specified with the \fBcount\fR directive.
378
\fBtabooext\fR [+] \fIlist\fR
336
379
The current taboo extension list is changed (see the \fBinclude\fR directive
337
for information on the taboo extensions). If \fB+\fR precedes \fIlist\fR,
338
the current taboo extension list is augmented by \fIlist\fR, otherwise
339
it is replaced. At startup, the taboo extension list
340
contains .rpmorig, .rpmsave, .dpkg-dist, .dpkg-old, .dpkg-new, .disabled,
341
,v, .swp, .rpmnew, and ~. The members of the list are separated by spaces,
380
for information on the taboo extensions). If a + precedes the list of
381
extensions, the current taboo extension list is augmented, otherwise it
382
is replaced. At startup, the taboo extension list
383
contains .rpmorig, .rpmsave, ,v, .swp, .rpmnew, and ~.
346
Log files are rotated if the current weekday is less than the weekday
347
of the last rotation or if more than a week has passed since the last
387
Log files are rotated if the current weekday is less then the weekday
388
of the last rotation or if more then a week has passed since the last
348
389
rotation. This is normally the same as rotating logs on the first day
349
of the week, but works better if \fBlogrotate\fR is not run every
390
of the week, but it works better if \fIlogrotate\fR is not run every