~ubuntu-branches/ubuntu/edgy/logrotate/edgy

« back to all changes in this revision

Viewing changes to logrotate.8

  • Committer: Bazaar Package Importer
  • Author(s): Paul Martin
  • Date: 2004-06-11 13:51:34 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040611135134-xwwlztb186794ikt
Tags: 3.7-2
* Added commented out stuff in debian/rules to build a 
  logrotate-selinux package should Russell's move to get libselinux1 
  made "base" fail.
* Patch: 21-taboo-to-debug, reduces the "Ignoring..." messages of
  the taboo filter from ERROR to DEBUG. (Closes: #249073)
* Patch: 30-config-h, changed to fix upstream bug with mailing
  logs. (Closes: #253837)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.TH LOGROTATE 8 "Thu Aug 02 2001"
 
1
.TH LOGROTATE 8 "Wed Nov 5 2002" "Red Hat Linux" "System Administrator's Manual"
2
2
.UC 4
3
3
.SH NAME
4
4
logrotate \- rotates, compresses, and mails system logs
5
5
.SH SYNOPSIS
6
 
\fBlogrotate\fR [\fB\-dv\fR] [\fB\-f\fR|\fB\-\-force\fR]
7
 
[\fB\-s\fR|\fB-\-state\ \fIstatefile\fR] \fIconfig_file\fR ..
 
6
\fBlogrotate\fR [-dv] [-f|--force] [-s|--state \fIfile\fR] \fIconfig_file\fR+
8
7
.SH DESCRIPTION
9
8
\fBlogrotate\fR is designed to ease administration of systems that generate
10
9
large numbers of log files.  It allows automatic rotation, compression, 
12
11
weekly, monthly, or when it grows too large.
13
12
.P
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. 
18
17
.P
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
26
25
a config file.
27
26
.P
37
36
be made to the logs or to the \fBlogrotate\fR state file.
38
37
 
39
38
.TP
40
 
\fB-f\fR, \fB-\-force\fR
 
39
\fB-f, -\-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
45
 
correctly.
46
 
 
47
 
.TP
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.
 
44
 
 
45
.TP
 
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
 
51
-s\fR.
 
52
 
 
53
.TP
 
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.
52
58
 
53
59
.TP
54
60
\fB-\-usage\fR
55
61
Prints a short usage message.
56
62
 
57
 
.TP
58
 
\fB-v\fR, \fB--verbose\fR
59
 
Display messages during rotation.
60
 
 
61
 
 
62
63
.SH CONFIGURATION FILE
63
64
 
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:
69
70
 
70
71
.nf
71
72
.ta +3i
76
77
    rotate 5
77
78
    weekly
78
79
    postrotate
79
 
        /sbin/killall -HUP syslogd
 
80
        /sbin/killall -HUP syslogd
80
81
    endscript
81
82
}
82
83
 
86
87
    size=100k
87
88
    sharedscripts
88
89
    postrotate
89
 
        /sbin/killall -HUP httpd
 
90
        /sbin/killall -HUP httpd
90
91
    endscript
91
92
}
92
93
 
93
 
/var/log/news/* {
 
94
/var/log/news/news.crit {
94
95
    monthly
95
96
    rotate 2
 
97
    olddir /var/log/news/old
96
98
    missingok
97
99
    postrotate
98
 
        kill -HUP `cat /var/run/inn.pid`
 
100
        kill -HUP `cat /var/run/inn.pid`
99
101
    endscript
100
102
    nocompress
101
103
}
105
107
The first few lines set global options; in the example, logs are
106
108
compressed after they are rotated.  Note that comments may appear
107
109
anywhere in the config file as long as the first non-whitespace
108
 
character on the line is a \fB#\fR.
 
110
character on the line is a #.
109
111
 
110
 
The next section of the config file defines how to handle the log file
 
112
The next section of the config files defined how to handle the log file
111
113
\fI/var/log/messages\fR. The log will go through five weekly rotations before
112
114
being removed. After the log file has been rotated (but before the old
113
115
version of the log has been compressed), the command 
115
117
 
116
118
The next section defines the parameters for both
117
119
\fI/var/log/httpd/access.log\fR and \fI/var/log/httpd/error.log\fR.
118
 
Each is rotated whenever it grows over 100k in size, and the old logs
 
120
They are rotated whenever is grows over 100k is size, and the old logs
119
121
files are mailed (uncompressed) to www@my.org after going through 5
120
122
rotations, rather then being removed. The \fBsharedscripts\fR means that
121
123
the \fBpostrotate\fR script will only be run once, not once for each
122
 
log which is rotated. Note that log file names may be enclosed in
123
 
quotes (and that quotes are required if the name contains spaces).
124
 
Normal shell quoting rules apply, with \fB'\fR, \fB"\fR, and \fB\\\fR
 
124
log which is rotated. Note that the double quotes around the first filename
 
125
at the beginning of this section allows logrotate to rotate logs with
 
126
spaces in the name. Normal shell quoting rules apply, with ', ", and \\
125
127
characters supported.
126
128
 
127
129
The last section defines the parameters for all of the files in
129
131
considered a single rotation directive and if errors occur for more then
130
132
one file, the log files are not compressed.
131
133
 
132
 
If the directory \fI/var/log/news\fR does not exist, this will cause 
133
 
\fBlogrotate\fR to report an error. This error cannot be stopped with
134
 
the \fBmissingok\fR directive.
 
134
Please use wildcards with caution.  If you specify *, \fBlogrotate\fR will
 
135
rotate all files, including previously rotated ones.  A way around this
 
136
is to use the \fBolddir\fR directive or a more exact wildcard (such as *.log).
135
137
 
136
138
Here is more information on the directives which may be included in
137
139
a \fBlogrotate\fR configuration file:
138
140
 
139
141
.TP
140
142
\fBcompress\fR
141
 
Old versions of log files are compressed with \fBgzip\fR(1) by default.
142
 
See also \fBnocompress\fR. 
 
143
Old versions of log files are compressed with \fBgzip\fR by default. See also
 
144
\fBnocompress\fR. 
143
145
 
144
146
.TP
145
147
\fBcompresscmd\fR
146
148
Specifies which command to use to compress log files.  The default is
147
 
\fBgzip\fR(1).  See also \fBcompress\fR.
 
149
\fBgzip\fR.  See also \fBcompress\fR.
148
150
 
149
151
.TP
150
152
\fBuncompresscmd\fR
151
153
Specifies which command to use to uncompress log files.  The default is
152
 
\fBgunzip\fR(1).
 
154
\fBgunzip\fR.
153
155
 
154
156
.TP
155
157
\fBcompressext\fR
163
165
in use.  The default, for \fBgzip\fR, is "-9" (maximum compression).
164
166
 
165
167
.TP
 
168
\fBcopy\fR
 
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.
 
174
 
 
175
.TP
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.
178
188
Immediately after rotation (before the \fBpostrotate\fR script is run)
179
189
the log file is created (with the same name as the log file just rotated).
180
190
\fImode\fR specifies the mode for the log file in octal (the same
181
 
as \fBchmod\fR(2)), \fIowner\fR specifies the user name who will own the
 
191
as \fBchmod(2)\fR), \fIowner\fR specifies the user name who will own the
182
192
log file, and \fIgroup\fR specifies the group the log file will belong
183
193
to. Any of the log file attributes may be omitted, in which case those
184
194
attributes for the new file will use the same values as the original log
192
202
.TP
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.
198
208
 
199
209
.TP
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.
204
214
 
205
215
.TP
206
216
\fBifempty\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).
209
219
 
210
220
.TP
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
219
 
file definition.
 
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
 
230
definition.
220
231
 
221
232
.TP
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
225
236
may be used.
226
237
 
246
257
 
247
258
.TP
248
259
\fBnocompress\fR
249
 
Old versions of log files are not compressed. See also \fBcompress\fR. 
 
260
Old versions of log files are not compressed with \fBgzip\fR. See also
 
261
\fBcompress\fR. 
 
262
 
 
263
.TP
 
264
\fBnocopy\fR
 
265
Do not copy the original log file and leave it in place.
 
266
(this overrides the \fBcopy\fR option).
250
267
 
251
268
.TP
252
269
\fBnocopytruncate\fR
264
281
 
265
282
.TP
266
283
\fBnomail\fR
267
 
Do not mail old log files to any address.
 
284
Don't mail old log files to any address.
268
285
 
269
286
.TP
270
287
\fBnomissingok\fR
272
289
 
273
290
.TP
274
291
\fBnoolddir\fR
275
 
Logs are rotated in the directory they normally reside in (this 
 
292
Logs are rotated in the same directory the log normally resides in (this 
276
293
overrides the \fBolddir\fR option).
277
294
 
278
295
.TP
279
296
\fBnosharedscripts\fR
280
 
Run \fBprerotate\fR and \fBpostrotate\fR scripts for every log that
 
297
Run \fBprerotate\fR and \fBpostrotate\fR scripts for every script which
281
298
is rotated (this is the default, and overrides the \fBsharedscripts\fR
282
299
option).
283
300
 
287
304
 
288
305
.TP
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.
294
313
 
295
314
.TP
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.
301
320
 
302
321
.TP
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
 
327
as well.
 
328
 
 
329
.TP
 
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.
 
336
 
 
337
.TP
 
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.
308
344
 
309
345
.TP
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.
314
350
 
315
351
.TP
 
352
\fBsize \fIsize\fR
 
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.
 
357
 
 
358
.TP
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.
326
 
 
327
 
.TP
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.
333
 
 
334
 
.TP
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
 
367
option.
 
368
 
 
369
.TP
 
370
\fBstart \fIcount\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.
 
376
 
 
377
.TP
 
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,
342
 
not commas.
 
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 ~.
343
384
 
344
385
.TP
345
386
\fBweekly\fR
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
350
391
night.
351
392
 
352
393
.SH FILES
359
400
Configuration options.
360
401
 
361
402
.SH SEE ALSO
362
 
.BR gzip (1)
363
 
 
364
 
.SH NOTES
365
 
The \fBkillall\fR(1) program in Debian is found in the \fIpsmisc\fR package.
 
403
.IR gzip (1)
366
404
 
367
405
.SH AUTHORS
368
406
.nf