| 1 |
'\" t |
| 2 |
.TH LOGROTATE 8 "3.22.0" "Linux" "System Administrator's Manual" |
| 3 |
.\" Per groff_man(7), the TQ macro should be copied from an-ext.tmac when |
| 4 |
.\" not running under groff. That's not quite right; not all groff |
| 5 |
.\" installations include this macro. So bring it in with another name |
| 6 |
.\" unconditionally. |
| 7 |
.\" Continuation line for .TP header. |
| 8 |
.de tq |
| 9 |
. br |
| 10 |
. ns |
| 11 |
. TP \\$1\" no doublequotes around argument! |
| 12 |
.. |
| 13 |
|
| 14 |
.SH NAME |
| 15 |
|
| 16 |
logrotate \(hy rotates, compresses, and mails system logs |
| 17 |
|
| 18 |
.SH SYNOPSIS |
| 19 |
|
| 20 |
\fBlogrotate\fR |
| 21 |
\fR[\fB\-\-force\fR] |
| 22 |
\fR[\fB\-\-debug\fR] |
| 23 |
\fR[\fB\-\-state\fR \fIfile\fR] |
| 24 |
\fR[\fB\-\-skip-state-lock\fR] |
| 25 |
\fR[\fB\-\-wait-for-state-lock\fR] |
| 26 |
\fR[\fB\-\-verbose\fR] |
| 27 |
\fR[\fB\-\-log\fR \fIfile\fR] |
| 28 |
\fR[\fB\-\-mail\fR \fIcommand\fR] |
| 29 |
\fIconfig_file\fR |
| 30 |
\fR[\fIconfig_file2 ...\fR] |
| 31 |
|
| 32 |
.SH DESCRIPTION |
| 33 |
|
| 34 |
\fBlogrotate\fR is designed to ease administration of systems that generate |
| 35 |
large numbers of log files. It allows automatic rotation, compression, |
| 36 |
removal, and mailing of log files. Each log file may be handled daily, |
| 37 |
weekly, monthly, or when it grows too large. |
| 38 |
.P |
| 39 |
Normally, \fBlogrotate\fR is run as a daily cron job. It will not modify |
| 40 |
a log more than once in one day unless the criterion for that log is |
| 41 |
based on the log's size and \fBlogrotate\fR is being run more than once |
| 42 |
each day, or unless the \fB\-f\fR or \fB\-\-force\fR option is used. |
| 43 |
.P |
| 44 |
Any number of config files may be given on the command line. Later config |
| 45 |
files may override the options given in earlier files, so the order |
| 46 |
in which the \fBlogrotate\fR config files are listed is important. |
| 47 |
Normally, a single config file which includes any other config files |
| 48 |
which are needed should be used. See below for more information on how |
| 49 |
to use the \fBinclude\fR directive to accomplish this. If a directory |
| 50 |
is given on the command line, every file in that directory is used as |
| 51 |
a config file. |
| 52 |
.P |
| 53 |
If no command line arguments are given, \fBlogrotate\fR will print |
| 54 |
version and copyright information, along with a short usage summary. If |
| 55 |
any errors occur while rotating logs, \fBlogrotate\fR will exit with |
| 56 |
non-zero status, although the state file will be updated. |
| 57 |
|
| 58 |
.SH OPTIONS |
| 59 |
|
| 60 |
.TP |
| 61 |
\fB\-f\fR, \fB\-\-force\fR |
| 62 |
Tells \fBlogrotate\fR to force the rotation, even if it doesn't think |
| 63 |
this is necessary. Sometimes this is useful after adding new entries to |
| 64 |
a \fBlogrotate\fR config file, or if old log files have been removed |
| 65 |
by hand, as the new files will be created, and logging will continue |
| 66 |
correctly. |
| 67 |
|
| 68 |
.TP |
| 69 |
\fB\-d\fR, \fB\-\-debug\fR |
| 70 |
Turn on debug mode, which means that no changes are made to the logs and the |
| 71 |
\fBlogrotate\fR state file is not updated. Only debug messages are printed. |
| 72 |
|
| 73 |
.TP |
| 74 |
\fB\-s\fR, \fB\-\-state\fR \fIstatefile\fR |
| 75 |
Tells \fBlogrotate\fR to use an alternate state file. This is useful |
| 76 |
if \fBlogrotate\fR is being run as a different user for various sets of |
| 77 |
log files. To prevent parallel execution \fBlogrotate\fR by default |
| 78 |
acquires a lock on the state file, if it cannot be acquired \fBlogrotate\fR |
| 79 |
will exit with value 3. |
| 80 |
The default state file is \fI/var/lib/logrotate/status\fR. |
| 81 |
If \fI/dev/null\fR is given as the state file, then \fBlogrotate\fR will |
| 82 |
not try to lock or write the state file. |
| 83 |
|
| 84 |
.TP |
| 85 |
\fB\-\-skip-state-lock\fR |
| 86 |
Do not lock the state file, for example if locking is unsupported or prohibited. |
| 87 |
|
| 88 |
.TP |
| 89 |
\fB\-\-wait-for-state-lock\fR |
| 90 |
Wait until lock on the state file is released by another logrotate process. |
| 91 |
This option may cause logrotate to wait indefinitely. Use with caution. |
| 92 |
|
| 93 |
.TP |
| 94 |
\fB\-v\fR, \fB\-\-verbose\fR |
| 95 |
Turns on verbose mode, for example to display messages during rotation. |
| 96 |
|
| 97 |
.TP |
| 98 |
\fB\-l\fR, \fB\-\-log\fR \fIfile\fR |
| 99 |
Tells \fBlogrotate\fR to log verbose output into the log_file. The verbose |
| 100 |
output logged to that file is the same as when running \fBlogrotate\fR with |
| 101 |
\fB-v\fR switch. The log file is overwritten on every \fBlogrotate\fR |
| 102 |
execution. |
| 103 |
|
| 104 |
.TP |
| 105 |
\fB\-m\fR, \fB\-\-mail\fR \fIcommand\fR |
| 106 |
Tells \fBlogrotate\fR which command to use when mailing logs. This |
| 107 |
command should accept the following arguments: |
| 108 |
.IP |
| 109 |
1) the subject of the message given with '-s subject' |
| 110 |
.br |
| 111 |
2) the recipient. |
| 112 |
.IP |
| 113 |
The command must then read a message on standard input |
| 114 |
and mail it to the recipient. The default mail command is |
| 115 |
\fI/usr/bin/mail\fR. |
| 116 |
|
| 117 |
.TP |
| 118 |
\fB\-\-usage\fR |
| 119 |
Prints a short usage message. |
| 120 |
|
| 121 |
.TP |
| 122 |
\fB\-?\fR, \fB\-\-help\fR |
| 123 |
Prints help message. |
| 124 |
|
| 125 |
.TP |
| 126 |
\fB\-\-version\fR |
| 127 |
Display version information. |
| 128 |
|
| 129 |
|
| 130 |
.SH CONFIGURATION FILE |
| 131 |
|
| 132 |
\fBlogrotate\fR reads everything about the log files it should be handling |
| 133 |
from the series of configuration files specified on the command line. Each |
| 134 |
configuration file can set global options (local definitions override |
| 135 |
global ones, and later definitions override earlier ones) and specify |
| 136 |
logfiles to rotate. Global options do not affect preceding include |
| 137 |
directives. A simple configuration file looks like this: |
| 138 |
|
| 139 |
.nf |
| 140 |
.ta +8n |
| 141 |
# sample logrotate configuration file |
| 142 |
compress |
| 143 |
|
| 144 |
/var/log/messages { |
| 145 |
rotate 5 |
| 146 |
weekly |
| 147 |
postrotate |
| 148 |
/usr/bin/killall \-HUP syslogd |
| 149 |
endscript |
| 150 |
} |
| 151 |
|
| 152 |
"/var/log/httpd/access.log" /var/log/httpd/error.log { |
| 153 |
rotate 5 |
| 154 |
mail [email protected] |
| 155 |
size 100k |
| 156 |
sharedscripts |
| 157 |
postrotate |
| 158 |
/usr/bin/killall \-HUP httpd |
| 159 |
endscript |
| 160 |
} |
| 161 |
|
| 162 |
/var/log/news/* { |
| 163 |
monthly |
| 164 |
rotate 2 |
| 165 |
olddir /var/log/news/old |
| 166 |
missingok |
| 167 |
sharedscripts |
| 168 |
postrotate |
| 169 |
kill \-HUP $(cat /var/run/inn.pid) |
| 170 |
endscript |
| 171 |
nocompress |
| 172 |
} |
| 173 |
|
| 174 |
~/log/*.log {} |
| 175 |
|
| 176 |
.fi |
| 177 |
|
| 178 |
.PP |
| 179 |
The first few lines set global options; in the example, logs are |
| 180 |
compressed after they are rotated. Note that comments may appear |
| 181 |
anywhere in the config file as long as the first non-whitespace |
| 182 |
character on the line is a \fB#\fR. |
| 183 |
|
| 184 |
Values are separated from directives by whitespace and/or an optional =. |
| 185 |
Numbers must be specified in a format understood by \fBstrtoul\fR(3). |
| 186 |
|
| 187 |
The next section of the config file defines how to handle the log file |
| 188 |
\fI/var/log/messages\fR. The log will go through five weekly rotations before |
| 189 |
being removed. After the log file has been rotated (but before the old |
| 190 |
version of the log has been compressed), the command |
| 191 |
\fI/usr/bin/killall \-HUP syslogd\fR will be executed. |
| 192 |
|
| 193 |
The next section defines the parameters for both |
| 194 |
\fI/var/log/httpd/access.log\fR and \fI/var/log/httpd/error.log\fR. |
| 195 |
Each is rotated whenever it grows over 100\ kilobytes in size, and the old logs |
| 196 |
files are mailed (uncompressed) to recipient@\:example.org after going through 5 |
| 197 |
rotations, rather than being removed. The \fBsharedscripts\fR means that |
| 198 |
the \fBpostrotate\fR script will only be run once for this section, not once |
| 199 |
for each log which is rotated. |
| 200 |
Note that log file names may be enclosed in |
| 201 |
quotes (and that quotes are required if the name contains spaces). |
| 202 |
Normal shell quoting rules apply, with \fB'\fR, \fB"\fR, and \fB\e\fR |
| 203 |
characters supported. |
| 204 |
|
| 205 |
The next section defines the parameters for all of the files in |
| 206 |
\fI/var/log/news\fR. Each file is rotated on a monthly basis. |
| 207 |
|
| 208 |
The last section uses tilde expansion to rotate log files in the home |
| 209 |
directory of the current user. This is only available, if your glob |
| 210 |
library supports tilde expansion. GNU glob does support this. |
| 211 |
|
| 212 |
Please use wildcards with caution. If you specify *, \fBlogrotate\fR will |
| 213 |
rotate all files, including previously rotated ones. A way around this |
| 214 |
is to use the \fBolddir\fR directive or a more exact wildcard (such as *.log). |
| 215 |
|
| 216 |
Please note, by default when using \fBsystemd\fR(1), the option |
| 217 |
\fIProtectSystem=full\fR is set in the \fIlogrotate.service\fR file. |
| 218 |
This prevents \fBlogrotate\fR from modifying logs in \fI/etc\fR |
| 219 |
and \fI/usr\fR. |
| 220 |
|
| 221 |
Here is more information on the directives which may be included in |
| 222 |
a \fBlogrotate\fR configuration file: |
| 223 |
|
| 224 |
.SH CONFIGURATION FILE DIRECTIVES |
| 225 |
These directives may be included in a \fBlogrotate\fR configuration file: |
| 226 |
|
| 227 |
.SS Rotation |
| 228 |
|
| 229 |
.TP |
| 230 |
\fBrotate \fIcount\fR |
| 231 |
Log files are rotated \fIcount\fR times before being removed or mailed to the |
| 232 |
address specified in a \fBmail\fR directive. If \fIcount\fR is 0, old versions |
| 233 |
are removed rather than rotated. If \fIcount\fR is \-1, old logs are not |
| 234 |
removed at all, except they are affected by \fBmaxage\fR (use with caution, may |
| 235 |
waste performance and disk space). Default is 0. |
| 236 |
|
| 237 |
.TP |
| 238 |
\fBolddir \fIdirectory\fR |
| 239 |
Logs are moved into \fIdirectory\fR for rotation. The \fIdirectory\fR must be |
| 240 |
on the same physical device as the log file being rotated, unless \fBcopy\fR, |
| 241 |
\fBcopytruncate\fR or \fBrenamecopy\fR option is used. The \fIdirectory\fR |
| 242 |
is assumed to be relative to the directory holding the log file |
| 243 |
unless an absolute path name is specified. When this option is used all |
| 244 |
old versions of the log end up in \fIdirectory\fR. This option may be |
| 245 |
overridden by the \fBnoolddir\fR option. |
| 246 |
|
| 247 |
.TP |
| 248 |
\fBnoolddir\fR |
| 249 |
Logs are rotated in the directory they normally reside in (this |
| 250 |
overrides the \fBolddir\fR option). |
| 251 |
|
| 252 |
.TP |
| 253 |
\fBsu \fIuser\fR \fIgroup\fR |
| 254 |
Rotate log files set under this user and group instead of using default |
| 255 |
user/group (usually root). \fIuser\fR specifies the user used for |
| 256 |
rotation and \fIgroup\fR specifies the group used for rotation (see the |
| 257 |
section \fBUSER AND GROUP\fR for details). If the |
| 258 |
user/group you specify here does not have sufficient privilege to make |
| 259 |
files with the ownership you've specified in a \fBcreate\fR directive, |
| 260 |
it will cause an error. If \fBlogrotate\fR runs with root privileges, it is |
| 261 |
recommended to use the \fBsu\fR directive to rotate files in directories |
| 262 |
that are directly or indirectly in control of non-privileged users. |
| 263 |
|
| 264 |
.SS Frequency |
| 265 |
|
| 266 |
.TP |
| 267 |
\fBhourly\fR |
| 268 |
Log files are rotated every hour. Note that usually \fBlogrotate\fR is |
| 269 |
configured to be run by cron daily (or by \fIlogrotate.timer\fR when using |
| 270 |
\fBsystemd\fR(1)). You have to change this configuration and run |
| 271 |
\fBlogrotate\fR hourly to be able to really rotate logs hourly. |
| 272 |
|
| 273 |
.TP |
| 274 |
\fBdaily\fR |
| 275 |
Log files are rotated every day. |
| 276 |
|
| 277 |
.TP |
| 278 |
\fBweekly\fR [\fIweekday\fR] |
| 279 |
Log files are rotated once each \fIweekday\fR, or if the date is advanced by at |
| 280 |
least 7 days since the last rotation (while ignoring the exact time). The |
| 281 |
\fIweekday\fR interpretation is following: 0 means Sunday, 1 means Monday, |
| 282 |
\&.\|.\|.\|\&, 6 means Saturday; the special value 7 means each 7 days, |
| 283 |
irrespectively of weekday. |
| 284 |
Defaults to 0 if the \fIweekday\fR argument is omitted. |
| 285 |
|
| 286 |
.TP |
| 287 |
\fBmonthly\fR |
| 288 |
Log files are rotated the first time \fBlogrotate\fR is run in a month |
| 289 |
(this is normally on the first day of the month). |
| 290 |
|
| 291 |
.TP |
| 292 |
\fByearly\fR |
| 293 |
Log files are rotated if the current year is not the same as the last rotation. |
| 294 |
|
| 295 |
.TP |
| 296 |
\fBsize \fIsize\fR |
| 297 |
Log files are rotated only if they grow bigger than \fIsize\fR bytes. If |
| 298 |
\fIsize\fR is followed by \fIk\fR, the size is assumed to be in kilobytes. |
| 299 |
If \fIM\fR is used, the size is in megabytes, and if \fIG\fR is used, the |
| 300 |
size is in gigabytes. So \fIsize 100\fR, \fIsize 100k\fR, \fIsize 100M\fR and |
| 301 |
\fIsize 100G\fR are all valid. This option is mutually exclusive with the time |
| 302 |
interval options, and it causes log files to be rotated without regard for the |
| 303 |
last rotation time, if specified after the time criteria (the last specified |
| 304 |
option takes the precedence). |
| 305 |
|
| 306 |
.SS File selection |
| 307 |
|
| 308 |
.TP |
| 309 |
\fBmissingok\fR |
| 310 |
If the log file is missing, go on to the next one without issuing an error |
| 311 |
message. See also \fBnomissingok\fR. |
| 312 |
|
| 313 |
.TP |
| 314 |
\fBnomissingok\fR |
| 315 |
If a log file does not exist, issue an error. This is the default. |
| 316 |
|
| 317 |
.TP |
| 318 |
\fBignoreduplicates\fR |
| 319 |
Ignore any following matches of a log file. |
| 320 |
|
| 321 |
.TP |
| 322 |
\fBifempty\fR |
| 323 |
Rotate the log file even if it is empty, overriding the \fBnotifempty\fR |
| 324 |
option (\fBifempty\fR is the default). |
| 325 |
|
| 326 |
.TP |
| 327 |
\fBnotifempty\fR |
| 328 |
Do not rotate the log if it is empty (this overrides the \fBifempty\fR option). |
| 329 |
|
| 330 |
.TP |
| 331 |
\fBminage\fR \fIcount\fR |
| 332 |
Do not rotate logs which are less than <count> days old. |
| 333 |
|
| 334 |
.TP |
| 335 |
\fBmaxage\fR \fIcount\fR |
| 336 |
Remove rotated logs older than <count> days. The age is only checked |
| 337 |
if the logfile is to be rotated. \fBrotate \-1\fR does not hinder removal. |
| 338 |
The files are mailed to the configured address if \fBmaillast\fR and |
| 339 |
\fBmail\fR are configured. |
| 340 |
|
| 341 |
.TP |
| 342 |
\fBminsize\fR \fIsize\fR |
| 343 |
Log files are rotated when they grow bigger than \fIsize\fR bytes, but not |
| 344 |
before the additionally specified time interval (\fBdaily\fR, \fBweekly\fR, |
| 345 |
\fBmonthly\fR, or \fByearly\fR). The related \fBsize\fR option is similar |
| 346 |
except that it is mutually exclusive with the time interval options, and it |
| 347 |
causes log files to be rotated without regard for the last rotation time, |
| 348 |
if specified after the time criteria (the last specified option takes the |
| 349 |
precedence). When \fBminsize\fR is used, both the size and timestamp of a |
| 350 |
log file are considered. |
| 351 |
|
| 352 |
.TP |
| 353 |
\fBmaxsize\fR \fIsize\fR |
| 354 |
Log files are rotated when they grow bigger than \fIsize\fR bytes even |
| 355 |
before the additionally specified time interval (\fBdaily\fR, \fBweekly\fR, |
| 356 |
\fBmonthly\fR, or \fByearly\fR). The related \fBsize\fR option is similar |
| 357 |
except that it is mutually exclusive with the time interval options, and it |
| 358 |
causes log files to be rotated without regard for the last rotation time, |
| 359 |
if specified after the time criteria (the last specified option takes the |
| 360 |
precedence). When \fBmaxsize\fR is used, both the size and timestamp of a |
| 361 |
log file are considered. |
| 362 |
|
| 363 |
.TP |
| 364 |
\fBtabooext\fR [+] \fIlist\fR |
| 365 |
The current taboo extension list is changed (see the \fBinclude\fR directive |
| 366 |
for information on the taboo extensions). If a + precedes the list of |
| 367 |
extensions, the current taboo extension list is augmented, otherwise it |
| 368 |
is replaced. At startup, the taboo extension list |
| 369 |
.IR ,v , |
| 370 |
.IR .bak , |
| 371 |
.IR .cfsaved , |
| 372 |
.IR .disabled , |
| 373 |
.IR .dpkg\-bak , |
| 374 |
.IR .dpkg\-del , |
| 375 |
.IR .dpkg\-dist , |
| 376 |
.IR .dpkg\-new , |
| 377 |
.IR .dpkg\-old , |
| 378 |
.IR .dpkg\-tmp , |
| 379 |
.IR .new , |
| 380 |
.IR .old , |
| 381 |
.IR .orig , |
| 382 |
.IR .rhn\-cfg\-tmp\-* , |
| 383 |
.IR .rpmnew , |
| 384 |
.IR .rpmorig , |
| 385 |
.IR .rpmsave , |
| 386 |
.IR .swp , |
| 387 |
.IR .ucf\-dist , |
| 388 |
.IR .ucf\-new , |
| 389 |
.IR .ucf\-old , |
| 390 |
.I ~ |
| 391 |
|
| 392 |
.TP |
| 393 |
\fBtaboopat\fR [+] \fIlist\fR |
| 394 |
The current taboo glob pattern list is changed (see the \fBinclude\fR directive |
| 395 |
for information on the taboo extensions and patterns). If a + precedes the list |
| 396 |
of patterns, the current taboo pattern list is augmented, otherwise it |
| 397 |
is replaced. At startup, the taboo pattern list is empty. |
| 398 |
|
| 399 |
.SS Files and Folders |
| 400 |
|
| 401 |
.TP |
| 402 |
\fBcreate \fImode\fR \fIowner\fR \fIgroup\fR, \fBcreate \fIowner\fR \fIgroup\fR |
| 403 |
Immediately after rotation (before the \fBpostrotate\fR script is run) |
| 404 |
the log file is created (with the same name as the log file just rotated). |
| 405 |
\fImode\fR specifies the mode for the log file in octal (the same |
| 406 |
as \fBchmod\fR(2)), \fIowner\fR specifies the user who will own the |
| 407 |
log file, and \fIgroup\fR specifies the group the log file will belong |
| 408 |
to (see the section \fBUSER AND GROUP\fR for details). |
| 409 |
Any of the log file attributes may be omitted, in which case those |
| 410 |
attributes for the new file will use the same values as the original log |
| 411 |
file for the omitted attributes. This option can be disabled using the |
| 412 |
\fBnocreate\fR option. |
| 413 |
|
| 414 |
.TP |
| 415 |
\fBnocreate\fR |
| 416 |
New log files are not created (this overrides the \fBcreate\fR option). |
| 417 |
|
| 418 |
.TP |
| 419 |
\fBcreateolddir \fImode\fR \fR[\fIowner\fR \fR[\fIgroup\fR]\fR], \fBcreateolddir \fR[\fIowner\fR \fR[\fIgroup\fR]\fR] |
| 420 |
If the directory specified by \fBolddir\fR directive does not exist, it is |
| 421 |
created. \fImode\fR specifies the mode for the \fBolddir\fR directory |
| 422 |
in octal (the same as \fBchmod\fR(2)), \fIowner\fR specifies the user |
| 423 |
who will own the \fBolddir\fR directory, and \fIgroup\fR specifies the group |
| 424 |
the \fBolddir\fR directory will belong to (see the section \fBUSER AND GROUP\fR |
| 425 |
for details). If \fImode\fR is not specified, \fB0755\fR is assumed. |
| 426 |
This option can be disabled using the \fBnocreateolddir\fR option. |
| 427 |
|
| 428 |
.TP |
| 429 |
\fBnocreateolddir\fR |
| 430 |
\fBolddir\fR directory is not created by \fBlogrotate\fR when it does not exist. |
| 431 |
|
| 432 |
.TP |
| 433 |
\fBcopy\fR |
| 434 |
Make a copy of the log file, but don't change the original at all. |
| 435 |
This option can be used, for instance, to make a snapshot of the current |
| 436 |
log file, or when some other utility needs to truncate or parse the file. |
| 437 |
When this option is used, the \fBcreate\fR option will have no effect, |
| 438 |
as the old log file stays in place. The \fBcopy\fR option allows storing |
| 439 |
rotated log files on the different devices using \fBolddir\fR directive. |
| 440 |
|
| 441 |
.TP |
| 442 |
\fBnocopy\fR |
| 443 |
Do not copy the original log file and leave it in place. |
| 444 |
(this overrides the \fBcopy\fR option). |
| 445 |
|
| 446 |
.TP |
| 447 |
\fBcopytruncate\fR |
| 448 |
Truncate the original log file to zero size in place after creating a copy, |
| 449 |
instead of moving the old log file and optionally creating a new one. |
| 450 |
It can be used when some program cannot be told to close its logfile |
| 451 |
and thus might continue writing (appending) to the previous log file forever. |
| 452 |
Note that there is a very small time slice between copying the file and |
| 453 |
truncating it, so some logging data might be lost. |
| 454 |
When this option is used, the \fBcreate\fR option will have no effect, |
| 455 |
as the old log file stays in place. The \fBcopytruncate\fR option allows |
| 456 |
storing rotated log files on the different devices using \fBolddir\fR |
| 457 |
directive. The \fBcopytruncate\fR option implies \fBnorenamecopy\fR. |
| 458 |
|
| 459 |
.TP |
| 460 |
\fBnocopytruncate\fR |
| 461 |
Do not truncate the original log file in place after creating a copy |
| 462 |
(this overrides the \fBcopytruncate\fR option). |
| 463 |
|
| 464 |
.TP |
| 465 |
\fBrenamecopy\fR |
| 466 |
Log file is renamed to temporary filename in the same directory by adding |
| 467 |
".tmp" extension to it. After that, \fBpostrotate\fR script is run |
| 468 |
and log file is copied from temporary filename to final filename. In the end, |
| 469 |
temporary filename is removed. The \fBrenamecopy\fR option allows storing |
| 470 |
rotated log files on the different devices using \fBolddir\fR directive. |
| 471 |
The \fBrenamecopy\fR option implies \fBnocopytruncate\fR. |
| 472 |
|
| 473 |
.TP |
| 474 |
\fBnorenamecopy\fR |
| 475 |
Do not rename and copy the original log file |
| 476 |
(this overrides the \fBrenamecopy\fR option). |
| 477 |
|
| 478 |
.TP |
| 479 |
\fBshred\fR |
| 480 |
Delete log files using \fBshred\fR \-u instead of unlink(). This should |
| 481 |
ensure that logs are not readable after their scheduled deletion; this is |
| 482 |
off by default. See also \fBnoshred\fR. |
| 483 |
|
| 484 |
.TP |
| 485 |
\fBnoshred\fR |
| 486 |
Do not use \fBshred\fR when deleting old log files. See also \fBshred\fR. |
| 487 |
|
| 488 |
.TP |
| 489 |
\fBshredcycles\fR \fIcount\fR |
| 490 |
Asks GNU \fBshred\fR(1) to overwrite log files \fBcount\fR times before |
| 491 |
deletion. Without this option, \fBshred\fR's default will be used. |
| 492 |
|
| 493 |
.TP |
| 494 |
\fBallowhardlink\fR |
| 495 |
Rotate files with multiple hard links; this is off by default. The target file |
| 496 |
might get emptied, e.g. with \fBshred\fR or \fBcopytruncate\fR. Use with |
| 497 |
caution, especially when the log files are rotated as root. |
| 498 |
|
| 499 |
.TP |
| 500 |
\fBnoallowhardlink\fR |
| 501 |
Do not rotate files with multiple hard links. See also \fBallowhardlink\fR. |
| 502 |
|
| 503 |
.SS Compression |
| 504 |
|
| 505 |
.TP |
| 506 |
\fBcompress\fR |
| 507 |
Old versions of log files are compressed with \fBgzip\fR(1) by default. |
| 508 |
See also \fBnocompress\fR. |
| 509 |
|
| 510 |
.TP |
| 511 |
\fBnocompress\fR |
| 512 |
Old versions of log files are not compressed. See also \fBcompress\fR. |
| 513 |
|
| 514 |
.TP |
| 515 |
\fBcompresscmd\fR |
| 516 |
Specifies which command to use to compress log files. The default is |
| 517 |
\fBgzip\fR(1). See also \fBcompress\fR. |
| 518 |
|
| 519 |
.TP |
| 520 |
\fBuncompresscmd\fR |
| 521 |
Specifies which command to use to uncompress log files. The default is |
| 522 |
\fBgunzip\fR(1). |
| 523 |
|
| 524 |
.TP |
| 525 |
\fBcompressext\fR |
| 526 |
Specifies which extension to use on compressed logfiles, if compression |
| 527 |
is enabled. The default follows that of the configured compression |
| 528 |
command. |
| 529 |
|
| 530 |
.TP |
| 531 |
\fBcompressoptions\fR |
| 532 |
Command line options may be passed to the compression program, if one is |
| 533 |
in use. The default, for \fBgzip\fR(1), is "\-6" (biased towards high |
| 534 |
compression at the expense of speed). |
| 535 |
If you use a different compression command, you may need to change the |
| 536 |
\fBcompressoptions\fR to match. |
| 537 |
|
| 538 |
.TP |
| 539 |
\fBdelaycompress\fR |
| 540 |
Postpone compression of the previous log file to the next rotation cycle. |
| 541 |
This only has effect when used in combination with \fBcompress\fR. |
| 542 |
It can be used when some program cannot be told to close its logfile |
| 543 |
and thus might continue writing to the previous log file for some time. |
| 544 |
|
| 545 |
.TP |
| 546 |
\fBnodelaycompress\fR |
| 547 |
Do not postpone compression of the previous log file to the next rotation cycle |
| 548 |
(this overrides the \fBdelaycompress\fR option). |
| 549 |
|
| 550 |
.SS Filenames |
| 551 |
|
| 552 |
.TP |
| 553 |
\fBextension \fIext\fR |
| 554 |
Log files with \fIext\fR extension can keep it after the rotation. |
| 555 |
If compression is used, the compression extension (normally \fI.gz\fR) |
| 556 |
appears after \fIext\fR. For example you have a logfile named mylog.foo |
| 557 |
and want to rotate it to mylog.1.foo.gz instead of mylog.foo.1.gz. |
| 558 |
|
| 559 |
.TP |
| 560 |
\fBaddextension \fIext\fR |
| 561 |
Log files are given the final extension \fIext\fR after rotation. If |
| 562 |
the original file already ends with \fIext\fR, the extension is not |
| 563 |
duplicated, but merely moved to the end, that is both \fBfilename\fR and |
| 564 |
\fBfilename\fIext\fR would get rotated to filename.1\fIext\fR. If |
| 565 |
compression is used, the compression extension (normally \fB.gz\fR) |
| 566 |
appears after \fIext\fR. |
| 567 |
|
| 568 |
.TP |
| 569 |
\fBstart \fIcount\fR |
| 570 |
This is the number to use as the base for rotation. For example, if |
| 571 |
you specify 0, the logs will be created with a .0 extension as they are |
| 572 |
rotated from the original log files. If you specify 9, log files will |
| 573 |
be created with a .9, skipping 0\(en8. Files will still be rotated the |
| 574 |
number of times specified with the \fBrotate\fR directive. |
| 575 |
|
| 576 |
.TP |
| 577 |
\fBdateext\fR |
| 578 |
Archive old versions of log files adding a date extension like YYYYMMDD |
| 579 |
instead of simply adding a number. The extension may be configured using |
| 580 |
the \fBdateformat\fR and \fBdateyesterday\fR options. |
| 581 |
|
| 582 |
.TP |
| 583 |
\fBnodateext\fR |
| 584 |
Do not archive old versions of log files with date extension |
| 585 |
(this overrides the \fBdateext\fR option). |
| 586 |
|
| 587 |
.TP |
| 588 |
\fBdateformat\fR \fIformat_string\fR |
| 589 |
Specify the extension for \fBdateext\fR using the notation similar to |
| 590 |
\fBstrftime\fR(3) function. Only %Y %m %d %H %M %S %V %s and %z specifiers are |
| 591 |
allowed. |
| 592 |
The default value is \-%Y%m%d except hourly, which uses \-%Y%m%d%H as default |
| 593 |
value. Note that also the character separating log name from the extension is |
| 594 |
part of the dateformat string. The system clock must be set past Sep 9th 2001 |
| 595 |
for %s to work correctly. |
| 596 |
Note that the datestamps generated by this format must be lexically sortable |
| 597 |
(that is first the year, then the month then the day. For example 2001/12/01 is |
| 598 |
ok, but 01/12/2001 is not, since 01/11/2002 would sort lower while it is later). |
| 599 |
This is because when using the \fBrotate\fR option, \fBlogrotate\fR sorts all |
| 600 |
rotated filenames to find out which logfiles are older and should be removed. |
| 601 |
|
| 602 |
.TP |
| 603 |
\fBdateyesterday\fR |
| 604 |
Use yesterday's instead of today's date to create the \fBdateext\fR |
| 605 |
extension, so that the rotated log file has a date in its name that is |
| 606 |
the same as the timestamps within it. |
| 607 |
|
| 608 |
.TP |
| 609 |
\fBdatehourago\fR |
| 610 |
Use hour ago instead of current date to create the \fBdateext\fR extension, |
| 611 |
so that the rotated log file has a hour in its name that is the same as the |
| 612 |
timestamps within it. Useful with rotate \fBhourly\fR. |
| 613 |
|
| 614 |
.SS Mail |
| 615 |
|
| 616 |
.TP |
| 617 |
\fBmail \fIaddress\fR |
| 618 |
When a log is rotated out of existence, it is mailed to \fIaddress\fR. If |
| 619 |
no mail should be generated by a particular log, the \fBnomail\fR directive |
| 620 |
may be used. |
| 621 |
|
| 622 |
.TP |
| 623 |
\fBnomail\fR |
| 624 |
Do not mail old log files to any address. |
| 625 |
|
| 626 |
.TP |
| 627 |
\fBmailfirst\fR |
| 628 |
When using the \fBmail\fR command, mail the just-rotated file, |
| 629 |
instead of the about-to-expire file. |
| 630 |
|
| 631 |
.TP |
| 632 |
\fBmaillast\fR |
| 633 |
When using the \fBmail\fR command, mail the about-to-expire file, |
| 634 |
instead of the just-rotated file (this is the default). |
| 635 |
|
| 636 |
.SS Additional config files |
| 637 |
|
| 638 |
.TP |
| 639 |
\fBinclude \fIfile_or_directory\fR |
| 640 |
Reads the file given as an argument as if it was included inline |
| 641 |
where the \fBinclude\fR directive appears. If a directory is given, |
| 642 |
most of the files in that directory are read in alphabetic order |
| 643 |
before processing of the including file continues. The only files |
| 644 |
which are ignored are files which are not regular files (such as |
| 645 |
directories and named pipes) and files whose names end with one of |
| 646 |
the taboo extensions or patterns, as specified by the \fBtabooext\fR |
| 647 |
or \fBtaboopat\fR directives, respectively. The given path may |
| 648 |
start with \fB~/\fR to make it relative to the home directory of |
| 649 |
the executing user. For security reasons configuration files must |
| 650 |
not be group-writable nor world-writable. |
| 651 |
|
| 652 |
.SS Scripts |
| 653 |
|
| 654 |
.TP |
| 655 |
\fBsharedscripts\fR |
| 656 |
Normally, \fBprerotate\fR and \fBpostrotate\fR scripts are run for each |
| 657 |
log which is rotated and the absolute path to the log file is passed as first |
| 658 |
argument to the script. That means a single script may be run multiple |
| 659 |
times for log file entries which match multiple files (such as the |
| 660 |
\fI/var/log/news/*\fR example). If \fBsharedscripts\fR is specified, the |
| 661 |
scripts are only run once, no matter how many logs match the wildcarded pattern, |
| 662 |
and whole pattern is passed to them. |
| 663 |
However, if none of the logs in the pattern require rotating, the scripts |
| 664 |
will not be run at all. If the scripts exit with error (or any log fails to |
| 665 |
rotate), the remaining actions will not be executed for any logs. This option |
| 666 |
overrides the \fBnosharedscripts\fR option. |
| 667 |
|
| 668 |
.TP |
| 669 |
\fBnosharedscripts\fR |
| 670 |
Run \fBprerotate\fR and \fBpostrotate\fR scripts for every log file which |
| 671 |
is rotated (this is the default, and overrides the \fBsharedscripts\fR |
| 672 |
option). The absolute path to the log file is passed as first argument |
| 673 |
to the script. The absolute path to the final rotated log file is passed as |
| 674 |
the second argument to the \fBpostrotate\fR script. If the scripts exit with |
| 675 |
error, the remaining actions will not be executed for the affected log only. |
| 676 |
|
| 677 |
.tq |
| 678 |
\fBfirstaction\fR |
| 679 |
.tq |
| 680 |
\ \ \ \ \fIscript\fR |
| 681 |
.tq |
| 682 |
\fBendscript\fR |
| 683 |
The \fIscript\fR is executed once |
| 684 |
before all log files that match the wildcarded pattern are rotated, before |
| 685 |
the prerotate script is run and only if at least one log will actually be |
| 686 |
rotated. These directives may only appear inside a log file definition. |
| 687 |
The whole pattern is passed to the script as its first argument. If the script |
| 688 |
exits with an error, no further processing is done. See also \fBlastaction\fR |
| 689 |
and the \fBSCRIPTS\fR section. |
| 690 |
|
| 691 |
.tq |
| 692 |
\fBlastaction\fR |
| 693 |
.tq |
| 694 |
\ \ \ \ \fIscript\fR |
| 695 |
.tq |
| 696 |
\fBendscript\fR |
| 697 |
The \fIscript\fR is executed once |
| 698 |
after all log files that match the wildcarded pattern are rotated, after the |
| 699 |
postrotate script is run and only if at least one log is rotated. These |
| 700 |
directives may only appear inside a log file definition. The whole pattern is |
| 701 |
passed to the script as its first argument. If the script exits |
| 702 |
with an error, just an error message is shown (as this is the last |
| 703 |
action). See also \fBfirstaction\fR and |
| 704 |
the \fBSCRIPTS\fR section. |
| 705 |
|
| 706 |
.tq |
| 707 |
\fBprerotate\fR |
| 708 |
.tq |
| 709 |
\ \ \ \ \fIscript\fR |
| 710 |
.tq |
| 711 |
\fBendscript\fR |
| 712 |
The \fIscript\fR is executed before the log file and its old logs are |
| 713 |
rotated and only if the log will actually be rotated. These |
| 714 |
directives may only appear inside a log file definition. Normally, |
| 715 |
the absolute path to the log file is passed as the first argument to the script. |
| 716 |
If \fBsharedscripts\fR is specified, the whole pattern is passed to the script. |
| 717 |
See also \fBpostrotate\fR and the \fBSCRIPTS\fR section. |
| 718 |
See \fBsharedscripts\fR and \fBnosharedscripts\fR for error handling. |
| 719 |
|
| 720 |
.tq |
| 721 |
\fBpostrotate\fR |
| 722 |
.tq |
| 723 |
\ \ \ \ \fIscript\fR |
| 724 |
.tq |
| 725 |
\fBendscript\fR |
| 726 |
The \fIscript\fR is executed after the log file is rotated and before the log |
| 727 |
file is being compressed. These directives may only appear inside a log file |
| 728 |
definition. Normally, the absolute path to the log file is |
| 729 |
passed as the first argument to the script and the absolute path to the final |
| 730 |
rotated log file is passed as the second argument to the script. If |
| 731 |
\fBsharedscripts\fR is specified, the whole pattern is passed as the first |
| 732 |
argument to the script, and the second argument is omitted. |
| 733 |
See also \fBprerotate\fR and the \fBSCRIPTS\fR section. |
| 734 |
See \fBsharedscripts\fR and \fBnosharedscripts\fR |
| 735 |
for error handling. |
| 736 |
|
| 737 |
.tq |
| 738 |
\fBpreremove\fR |
| 739 |
.tq |
| 740 |
\ \ \ \ \fIscript\fR |
| 741 |
.tq |
| 742 |
\fBendscript\fR |
| 743 |
The \fIscript\fR is executed |
| 744 |
once just |
| 745 |
before removal of a log file. \fBlogrotate\fR will pass |
| 746 |
the name of file which is soon to be removed as the first argument to the |
| 747 |
script. See also \fBfirstaction\fR and |
| 748 |
the \fBSCRIPTS\fR section. |
| 749 |
|
| 750 |
.SH SCRIPTS |
| 751 |
|
| 752 |
The lines between the starting keyword (e.g. \fBprerotate\fR) and |
| 753 |
\fBendscript\fR (both of which must appear on lines by themselves) are |
| 754 |
executed (using \fB/bin/sh\fR). |
| 755 |
The script inherits some traits from the \fBlogrotate\fR process, including |
| 756 |
stderr, stdout, the current directory, the environment, and the umask. |
| 757 |
Scripts are run as the invoking user and group, irrespective of any \fBsu\fR |
| 758 |
directive. If the \fB\-\-log\fR flag was specified, file descriptor 3 is the |
| 759 |
log file. The current working directory is unspecified. |
| 760 |
|
| 761 |
.SH USER AND GROUP |
| 762 |
|
| 763 |
User and group identifiers are resolved first by trying the textual |
| 764 |
representation and, in case it fails, afterwards by the numeric value. |
| 765 |
|
| 766 |
.SH FILES |
| 767 |
|
| 768 |
.TS |
| 769 |
tab(:); |
| 770 |
l l l. |
| 771 |
\fI/var/lib/logrotate/status\fR:Default state file. |
| 772 |
\fI/etc/logrotate.conf\fR:Configuration options. |
| 773 |
.TE |
| 774 |
|
| 775 |
|
| 776 |
.SH "SEE ALSO" |
| 777 |
|
| 778 |
.BR chmod (2), |
| 779 |
.BR gunzip (1), |
| 780 |
.BR gzip (1), |
| 781 |
.BR mail (1), |
| 782 |
.BR shred (1), |
| 783 |
.BR strftime (3), |
| 784 |
.BR strtoul (3), |
| 785 |
<https://github.com/logrotate/logrotate> |
| 786 |
|
| 787 |
.SH AUTHORS |
| 788 |
|
| 789 |
.nf |
| 790 |
Erik Troan, Preston Brown, Jan Kaluza. |
| 791 |
|
| 792 |
<https://github.com/logrotate/logrotate> |
| 793 |
|
| 794 |
.fi |