5 kx .TH LOGROTATE 8 "@VERSION@" "Linux" "System Administrator's Manual"
5 kx .\" Per groff_man(7), the TQ macro should be copied from an-ext.tmac when
5 kx .\" not running under groff. That's not quite right; not all groff
5 kx .\" installations include this macro. So bring it in with another name
5 kx .\" unconditionally.
5 kx .\" Continuation line for .TP header.
5 kx .de tq
5 kx . br
5 kx . ns
5 kx . TP \\$1\" no doublequotes around argument!
5 kx ..
5 kx .\}
5 kx .SH NAME
5 kx
5 kx logrotate \(hy rotates, compresses, and mails system logs
5 kx
5 kx .SH SYNOPSIS
5 kx
5 kx \fBlogrotate\fR
5 kx \fR[\fB\-\-force\fR]
5 kx \fR[\fB\-\-debug\fR]
5 kx \fR[\fB\-\-state\fR \fIfile\fR]
5 kx \fR[\fB\-\-skip-state-lock\fR]
5 kx \fR[\fB\-\-verbose\fR]
5 kx \fR[\fB\-\-log\fR \fIfile\fR]
5 kx \fR[\fB\-\-mail\fR \fIcommand\fR]
5 kx \fIconfig_file\fR
5 kx \fR[\fIconfig_file2 ...\fR]
5 kx
5 kx .SH DESCRIPTION
5 kx
5 kx \fBlogrotate\fR is designed to ease administration of systems that generate
5 kx large numbers of log files. It allows automatic rotation, compression,
5 kx removal, and mailing of log files. Each log file may be handled daily,
5 kx weekly, monthly, or when it grows too large.
5 kx .P
5 kx Normally, \fBlogrotate\fR is run as a daily cron job. It will not modify
5 kx a log more than once in one day unless the criterion for that log is
5 kx based on the log's size and \fBlogrotate\fR is being run more than once
5 kx each day, or unless the \fB\-f\fR or \fB\-\-force\fR option is used.
5 kx .P
5 kx Any number of config files may be given on the command line. Later config
5 kx files may override the options given in earlier files, so the order
5 kx in which the \fBlogrotate\fR config files are listed is important.
5 kx Normally, a single config file which includes any other config files
5 kx which are needed should be used. See below for more information on how
5 kx to use the \fBinclude\fR directive to accomplish this. If a directory
5 kx is given on the command line, every file in that directory is used as
5 kx a config file.
5 kx .P
5 kx If no command line arguments are given, \fBlogrotate\fR will print
5 kx version and copyright information, along with a short usage summary. If
5 kx any errors occur while rotating logs, \fBlogrotate\fR will exit with
5 kx non-zero status.
5 kx
5 kx .SH OPTIONS
5 kx
5 kx .TP
5 kx \fB\-f\fR, \fB\-\-force\fR
5 kx Tells \fBlogrotate\fR to force the rotation, even if it doesn't think
5 kx this is necessary. Sometimes this is useful after adding new entries to
5 kx a \fBlogrotate\fR config file, or if old log files have been removed
5 kx by hand, as the new files will be created, and logging will continue
5 kx correctly.
5 kx
5 kx .TP
5 kx \fB\-d\fR, \fB\-\-debug\fR
5 kx Turn on debug mode, which means that no changes are made to the logs and the
5 kx \fBlogrotate\fR state file is not updated. Only debug messages are printed.
5 kx
5 kx .TP
5 kx \fB\-s\fR, \fB\-\-state\fR \fIstatefile\fR
5 kx Tells \fBlogrotate\fR to use an alternate state file. This is useful
5 kx if \fBlogrotate\fR is being run as a different user for various sets of
5 kx log files. To prevent parallel execution \fBlogrotate\fR by default
5 kx acquires a lock on the state file, if it cannot be acquired \fBlogrotate\fR
5 kx will exit with value 3. The default state file is \fI@STATE_FILE_PATH@\fR.
5 kx
5 kx .TP
5 kx \fB\-\-skip-state-lock\fR
5 kx Do not lock the state file, for example if locking is unsupported or prohibited.
5 kx
5 kx .TP
5 kx \fB\-v\fR, \fB\-\-verbose\fR
5 kx Turns on verbose mode, for example to display messages during rotation.
5 kx
5 kx .TP
5 kx \fB\-l\fR, \fB\-\-log\fR \fIfile\fR
5 kx Tells \fBlogrotate\fR to log verbose output into the log_file. The verbose
5 kx output logged to that file is the same as when running \fBlogrotate\fR with
5 kx \fB-v\fR switch. The log file is overwritten on every \fBlogrotate\fR
5 kx execution.
5 kx
5 kx .TP
5 kx \fB\-m\fR, \fB\-\-mail\fR \fIcommand\fR
5 kx Tells \fBlogrotate\fR which command to use when mailing logs. This
5 kx command should accept the following arguments:
5 kx .IP
5 kx 1) the subject of the message given with '-s subject'
5 kx .br
5 kx 2) the recipient.
5 kx .IP
5 kx The command must then read a message on standard input
5 kx and mail it to the recipient. The default mail command is
5 kx \fI@DEFAULT_MAIL_COMMAND@\fR.
5 kx
5 kx .TP
5 kx \fB\-\-usage\fR
5 kx Prints a short usage message.
5 kx
5 kx .TP
5 kx \fB\-?\fR, \fB\-\-help\fR
5 kx Prints help message.
5 kx
5 kx .TP
5 kx \fB\-\-version\fR
5 kx Display version information.
5 kx
5 kx
5 kx .SH CONFIGURATION FILE
5 kx
5 kx \fBlogrotate\fR reads everything about the log files it should be handling
5 kx from the series of configuration files specified on the command line. Each
5 kx configuration file can set global options (local definitions override
5 kx global ones, and later definitions override earlier ones) and specify
5 kx logfiles to rotate. Global options do not affect preceding include
5 kx directives. A simple configuration file looks like this:
5 kx
5 kx .nf
5 kx .ta +8n
5 kx # sample logrotate configuration file
5 kx compress
5 kx
5 kx /var/log/messages {
5 kx rotate 5
5 kx weekly
5 kx postrotate
5 kx /usr/bin/killall \-HUP syslogd
5 kx endscript
5 kx }
5 kx
5 kx "/var/log/httpd/access.log" /var/log/httpd/error.log {
5 kx rotate 5
5 kx mail recipient@example.org
5 kx size 100k
5 kx sharedscripts
5 kx postrotate
5 kx /usr/bin/killall \-HUP httpd
5 kx endscript
5 kx }
5 kx
5 kx /var/log/news/* {
5 kx monthly
5 kx rotate 2
5 kx olddir /var/log/news/old
5 kx missingok
5 kx postrotate
5 kx kill \-HUP $(cat /var/run/inn.pid)
5 kx endscript
5 kx nocompress
5 kx }
5 kx
5 kx ~/log/*.log {}
5 kx
5 kx .fi
5 kx
5 kx .PP
5 kx The first few lines set global options; in the example, logs are
5 kx compressed after they are rotated. Note that comments may appear
5 kx anywhere in the config file as long as the first non-whitespace
5 kx character on the line is a \fB#\fR.
5 kx
5 kx Values are separated from directives by whitespace and/or an optional =.
5 kx Numbers must be specified in a format understood by \fBstrtoul\fR(3).
5 kx
5 kx The next section of the config file defines how to handle the log file
5 kx \fI/var/log/messages\fR. The log will go through five weekly rotations before
5 kx being removed. After the log file has been rotated (but before the old
5 kx version of the log has been compressed), the command
5 kx \fI/usr/bin/killall \-HUP syslogd\fR will be executed.
5 kx
5 kx The next section defines the parameters for both
5 kx \fI/var/log/httpd/access.log\fR and \fI/var/log/httpd/error.log\fR.
5 kx Each is rotated whenever it grows over 100\ kilobytes in size, and the old logs
5 kx files are mailed (uncompressed) to recipient@\:example.org after going through 5
5 kx rotations, rather than being removed. The \fBsharedscripts\fR means that
5 kx the \fBpostrotate\fR script will only be run once (after the old logs have
5 kx been compressed), not once for each log which is rotated.
5 kx Note that log file names may be enclosed in
5 kx quotes (and that quotes are required if the name contains spaces).
5 kx Normal shell quoting rules apply, with \fB'\fR, \fB"\fR, and \fB\e\fR
5 kx characters supported.
5 kx
5 kx The next section defines the parameters for all of the files in
5 kx \fI/var/log/news\fR. Each file is rotated on a monthly basis. This is
5 kx considered a single rotation directive and if errors occur for more than
5 kx one file, the log files are not compressed.
5 kx
5 kx The last section uses tilde expansion to rotate log files in the home
5 kx directory of the current user. This is only available, if your glob
5 kx library supports tilde expansion. GNU glob does support this.
5 kx
5 kx Please use wildcards with caution. If you specify *, \fBlogrotate\fR will
5 kx rotate all files, including previously rotated ones. A way around this
5 kx is to use the \fBolddir\fR directive or a more exact wildcard (such as *.log).
5 kx
5 kx Here is more information on the directives which may be included in
5 kx a \fBlogrotate\fR configuration file:
5 kx
5 kx .SH CONFIGURATION FILE DIRECTIVES
5 kx These directives may be included in a \fBlogrotate\fR configuration file:
5 kx
5 kx .SS Rotation
5 kx
5 kx .TP
5 kx \fBrotate \fIcount\fR
5 kx Log files are rotated \fIcount\fR times before being removed or mailed to the
5 kx address specified in a \fBmail\fR directive. If \fIcount\fR is 0, old versions
5 kx are removed rather than rotated. If \fIcount\fR is \-1, old logs are not
5 kx removed at all, except they are affected by \fBmaxage\fR (use with caution, may
5 kx waste performance and disk space). Default is 0.
5 kx
5 kx .TP
5 kx \fBolddir \fIdirectory\fR
5 kx Logs are moved into \fIdirectory\fR for rotation. The \fIdirectory\fR must be
5 kx on the same physical device as the log file being rotated, unless \fBcopy\fR,
5 kx \fBcopytruncate\fR or \fBrenamecopy\fR option is used. The \fIdirectory\fR
5 kx is assumed to be relative to the directory holding the log file
5 kx unless an absolute path name is specified. When this option is used all
5 kx old versions of the log end up in \fIdirectory\fR. This option may be
5 kx overridden by the \fBnoolddir\fR option.
5 kx
5 kx .TP
5 kx \fBnoolddir\fR
5 kx Logs are rotated in the directory they normally reside in (this
5 kx overrides the \fBolddir\fR option).
5 kx
5 kx .TP
5 kx \fBsu \fIuser\fR \fIgroup\fR
5 kx Rotate log files set under this user and group instead of using default
5 kx user/group (usually root). \fIuser\fR specifies the user used for
5 kx rotation and \fIgroup\fR specifies the group used for rotation (see the
5 kx section \fBUSER AND GROUP\fR for details). If the
5 kx user/group you specify here does not have sufficient privilege to make
5 kx files with the ownership you've specified in a \fBcreate\fR directive,
5 kx it will cause an error. If \fBlogrotate\fR runs with root privileges, it is
5 kx recommended to use the \fBsu\fR directive to rotate files in directories
5 kx that are directly or indirectly in control of non-privileged users.
5 kx
5 kx .SS Frequency
5 kx
5 kx .TP
5 kx \fBhourly\fR
5 kx Log files are rotated every hour. Note that usually \fBlogrotate\fR is
5 kx configured to be run by cron daily. You have to change this configuration
5 kx and run \fBlogrotate\fR hourly to be able to really rotate logs hourly.
5 kx
5 kx .TP
5 kx \fBdaily\fR
5 kx Log files are rotated every day.
5 kx
5 kx .TP
5 kx \fBweekly\fR [\fIweekday\fR]
5 kx Log files are rotated once each \fIweekday\fR, or if the date is advanced by at
5 kx least 7 days since the last rotation (while ignoring the exact time). The
5 kx \fIweekday\fR interpretation is following: 0 means Sunday, 1 means Monday,
5 kx \&.\|.\|.\|\&, 6 means Saturday; the special value 7 means each 7 days,
5 kx irrespectively of weekday.
5 kx Defaults to 0 if the \fIweekday\fR argument is omitted.
5 kx
5 kx .TP
5 kx \fBmonthly\fR
5 kx Log files are rotated the first time \fBlogrotate\fR is run in a month
5 kx (this is normally on the first day of the month).
5 kx
5 kx .TP
5 kx \fByearly\fR
5 kx Log files are rotated if the current year is not the same as the last rotation.
5 kx
5 kx .TP
5 kx \fBsize \fIsize\fR
5 kx Log files are rotated only if they grow bigger than \fIsize\fR bytes. If
5 kx \fIsize\fR is followed by \fIk\fR, the size is assumed to be in kilobytes.
5 kx If the \fIM\fR is used, the size is in megabytes, and if \fIG\fR is used, the
5 kx size is in gigabytes. So \fIsize 100\fR, \fIsize 100k\fR, \fIsize 100M\fR and
5 kx \fIsize 100G\fR are all valid. This option is mutually exclusive with the time
5 kx interval options, and it causes log files to be rotated without regard for the
5 kx last rotation time, if specified after the time criteria (the last specified
5 kx option takes the precedence).
5 kx
5 kx .SS File selection
5 kx
5 kx .TP
5 kx \fBmissingok\fR
5 kx If the log file is missing, go on to the next one without issuing an error
5 kx message. See also \fBnomissingok\fR.
5 kx
5 kx .TP
5 kx \fBnomissingok\fR
5 kx If a log file does not exist, issue an error. This is the default.
5 kx
5 kx .TP
5 kx \fBifempty\fR
5 kx Rotate the log file even if it is empty, overriding the \fBnotifempty\fR
5 kx option (\fBifempty\fR is the default).
5 kx
5 kx .TP
5 kx \fBnotifempty\fR
5 kx Do not rotate the log if it is empty (this overrides the \fBifempty\fR option).
5 kx
5 kx .TP
5 kx \fBminage\fR \fIcount\fR
5 kx Do not rotate logs which are less than <count> days old.
5 kx
5 kx .TP
5 kx \fBmaxage\fR \fIcount\fR
5 kx Remove rotated logs older than <count> days. The age is only checked
5 kx if the logfile is to be rotated. \fBrotate \-1\fR does not hinder removal.
5 kx The files are mailed to the configured address if \fBmaillast\fR and
5 kx \fBmail\fR are configured.
5 kx
5 kx .TP
5 kx \fBminsize\fR \fIsize\fR
5 kx Log files are rotated when they grow bigger than \fIsize\fR bytes, but not
5 kx before the additionally specified time interval (\fBdaily\fR, \fBweekly\fR,
5 kx \fBmonthly\fR, or \fByearly\fR). The related \fBsize\fR option is similar
5 kx except that it is mutually exclusive with the time interval options, and it
5 kx causes log files to be rotated without regard for the last rotation time,
5 kx if specified after the time criteria (the last specified option takes the
5 kx precedence). When \fBminsize\fR is used, both the size and timestamp of a
5 kx log file are considered.
5 kx
5 kx .TP
5 kx \fBmaxsize\fR \fIsize\fR
5 kx Log files are rotated when they grow bigger than \fIsize\fR bytes even
5 kx before the additionally specified time interval (\fBdaily\fR, \fBweekly\fR,
5 kx \fBmonthly\fR, or \fByearly\fR). The related \fBsize\fR option is similar
5 kx except that it is mutually exclusive with the time interval options, and it
5 kx causes log files to be rotated without regard for the last rotation time,
5 kx if specified after the time criteria (the last specified option takes the
5 kx precedence). When \fBmaxsize\fR is used, both the size and timestamp of a
5 kx log file are considered.
5 kx
5 kx .TP
5 kx \fBtabooext\fR [+] \fIlist\fR
5 kx The current taboo extension list is changed (see the \fBinclude\fR directive
5 kx for information on the taboo extensions). If a + precedes the list of
5 kx extensions, the current taboo extension list is augmented, otherwise it
5 kx is replaced. At startup, the taboo extension list
5 kx .IR ,v ,
5 kx .IR .cfsaved ,
5 kx .IR .disabled ,
5 kx .IR .dpkg\-bak ,
5 kx .IR .dpkg\-del ,
5 kx .IR .dpkg\-dist ,
5 kx .IR .dpkg\-new ,
5 kx .IR .dpkg\-old ,
5 kx .IR .rhn\-cfg\-tmp\-* ,
5 kx .IR .rpmnew ,
5 kx .IR .rpmorig ,
5 kx .IR .rpmsave ,
5 kx .IR .swp ,
5 kx .IR .ucf\-dist ,
5 kx .IR .ucf\-new ,
5 kx .IR .ucf\-old ,
5 kx .IR .new ,
5 kx .IR .old ,
5 kx .IR .orig ,
5 kx .IR .bak ,
5 kx .I ~
5 kx
5 kx .TP
5 kx \fBtaboopat\fR [+] \fIlist\fR
5 kx The current taboo glob pattern list is changed (see the \fBinclude\fR directive
5 kx for information on the taboo extensions and patterns). If a + precedes the list
5 kx of patterns, the current taboo pattern list is augmented, otherwise it
5 kx is replaced. At startup, the taboo pattern list is empty.
5 kx
5 kx .SS Files and Folders
5 kx
5 kx .TP
5 kx \fBcreate \fImode\fR \fIowner\fR \fIgroup\fR, \fBcreate \fIowner\fR \fIgroup\fR
5 kx Immediately after rotation (before the \fBpostrotate\fR script is run)
5 kx the log file is created (with the same name as the log file just rotated).
5 kx \fImode\fR specifies the mode for the log file in octal (the same
5 kx as \fBchmod\fR(2)), \fIowner\fR specifies the user who will own the
5 kx log file, and \fIgroup\fR specifies the group the log file will belong
5 kx to (see the section \fBUSER AND GROUP\fR for details).
5 kx Any of the log file attributes may be omitted, in which case those
5 kx attributes for the new file will use the same values as the original log
5 kx file for the omitted attributes. This option can be disabled using the
5 kx \fBnocreate\fR option.
5 kx
5 kx .TP
5 kx \fBnocreate\fR
5 kx New log files are not created (this overrides the \fBcreate\fR option).
5 kx
5 kx .TP
5 kx \fBcreateolddir \fImode\fR \fIowner\fR \fIgroup\fR
5 kx If the directory specified by \fBolddir\fR directive does not exist, it is
5 kx created. \fImode\fR specifies the mode for the \fBolddir\fR directory
5 kx in octal (the same as \fBchmod\fR(2)), \fIowner\fR specifies the user
5 kx who will own the \fBolddir\fR directory, and \fIgroup\fR specifies the group
5 kx the \fBolddir\fR directory will belong to (see the section \fBUSER AND GROUP
5 kx \fR for details). This option can be disabled using
5 kx the \fBnocreateolddir\fR option.
5 kx
5 kx .TP
5 kx \fBnocreateolddir\fR
5 kx \fBolddir\fR directory is not created by \fBlogrotate\fR when it does not exist.
5 kx
5 kx .TP
5 kx \fBcopy\fR
5 kx Make a copy of the log file, but don't change the original at all.
5 kx This option can be used, for instance, to make a snapshot of the current
5 kx log file, or when some other utility needs to truncate or parse the file.
5 kx When this option is used, the \fBcreate\fR option will have no effect,
5 kx as the old log file stays in place.
5 kx
5 kx .TP
5 kx \fBnocopy\fR
5 kx Do not copy the original log file and leave it in place.
5 kx (this overrides the \fBcopy\fR option).
5 kx
5 kx .TP
5 kx \fBcopytruncate\fR
5 kx Truncate the original log file to zero size in place after creating a copy,
5 kx instead of moving the old log file and optionally creating a new one.
5 kx It can be used when some program cannot be told to close its logfile
5 kx and thus might continue writing (appending) to the previous log file forever.
5 kx Note that there is a very small time slice between copying the file and
5 kx truncating it, so some logging data might be lost.
5 kx When this option is used, the \fBcreate\fR option will have no effect,
5 kx as the old log file stays in place.
5 kx
5 kx .TP
5 kx \fBnocopytruncate\fR
5 kx Do not truncate the original log file in place after creating a copy
5 kx (this overrides the \fBcopytruncate\fR option).
5 kx
5 kx .TP
5 kx \fBrenamecopy\fR
5 kx Log file is renamed to temporary filename in the same directory by adding
5 kx ".tmp" extension to it. After that, \fBpostrotate\fR script is run
5 kx and log file is copied from temporary filename to final filename. This allows
5 kx storing rotated log files on the different devices using \fBolddir\fR
5 kx directive. In the end, temporary filename is removed.
5 kx
5 kx .TP
5 kx \fBshred\fR
5 kx Delete log files using \fBshred\fR \-u instead of unlink(). This should
5 kx ensure that logs are not readable after their scheduled deletion; this is
5 kx off by default. See also \fBnoshred\fR.
5 kx
5 kx .TP
5 kx \fBnoshred\fR
5 kx Do not use \fBshred\fR when deleting old log files. See also \fBshred\fR.
5 kx
5 kx .TP
5 kx \fBshredcycles\fR \fIcount\fR
5 kx Asks GNU \fBshred\fR(1) to overwrite log files \fBcount\fR times before
5 kx deletion. Without this option, \fBshred\fR's default will be used.
5 kx
5 kx .SS Compression
5 kx
5 kx .TP
5 kx \fBcompress\fR
5 kx Old versions of log files are compressed with \fBgzip\fR(1) by default.
5 kx See also \fBnocompress\fR.
5 kx
5 kx .TP
5 kx \fBnocompress\fR
5 kx Old versions of log files are not compressed. See also \fBcompress\fR.
5 kx
5 kx .TP
5 kx \fBcompresscmd\fR
5 kx Specifies which command to use to compress log files. The default is
5 kx \fBgzip\fR(1). See also \fBcompress\fR.
5 kx
5 kx .TP
5 kx \fBuncompresscmd\fR
5 kx Specifies which command to use to uncompress log files. The default is
5 kx \fBgunzip\fR(1).
5 kx
5 kx .TP
5 kx \fBcompressext\fR
5 kx Specifies which extension to use on compressed logfiles, if compression
5 kx is enabled. The default follows that of the configured compression
5 kx command.
5 kx
5 kx .TP
5 kx \fBcompressoptions\fR
5 kx Command line options may be passed to the compression program, if one is
5 kx in use. The default, for \fBgzip\fR(1), is "\-6" (biased towards high
5 kx compression at the expense of speed).
5 kx If you use a different compression command, you may need to change the
5 kx \fBcompressoptions\fR to match.
5 kx
5 kx .TP
5 kx \fBdelaycompress\fR
5 kx Postpone compression of the previous log file to the next rotation cycle.
5 kx This only has effect when used in combination with \fBcompress\fR.
5 kx It can be used when some program cannot be told to close its logfile
5 kx and thus might continue writing to the previous log file for some time.
5 kx
5 kx .TP
5 kx \fBnodelaycompress\fR
5 kx Do not postpone compression of the previous log file to the next rotation cycle
5 kx (this overrides the \fBdelaycompress\fR option).
5 kx
5 kx .SS Filenames
5 kx
5 kx .TP
5 kx \fBextension \fIext\fR
5 kx Log files with \fIext\fR extension can keep it after the rotation.
5 kx If compression is used, the compression extension (normally \fI.gz\fR)
5 kx appears after \fIext\fR. For example you have a logfile named mylog.foo
5 kx and want to rotate it to mylog.1.foo.gz instead of mylog.foo.1.gz.
5 kx
5 kx .TP
5 kx \fBaddextension \fIext\fR
5 kx Log files are given the final extension \fIext\fR after rotation. If
5 kx the original file already ends with \fIext\fR, the extension is not
5 kx duplicated, but merely moved to the end, that is both \fBfilename\fR and
5 kx \fBfilename\fIext\fR would get rotated to filename.1\fIext\fR. If
5 kx compression is used, the compression extension (normally \fB.gz\fR)
5 kx appears after \fIext\fR.
5 kx
5 kx .TP
5 kx \fBstart \fIcount\fR
5 kx This is the number to use as the base for rotation. For example, if
5 kx you specify 0, the logs will be created with a .0 extension as they are
5 kx rotated from the original log files. If you specify 9, log files will
5 kx be created with a .9, skipping 0\(en8. Files will still be rotated the
5 kx number of times specified with the \fBrotate\fR directive.
5 kx
5 kx .TP
5 kx \fBdateext\fR
5 kx Archive old versions of log files adding a date extension like YYYYMMDD
5 kx instead of simply adding a number. The extension may be configured using
5 kx the \fBdateformat\fR and \fBdateyesterday\fR options.
5 kx
5 kx .TP
5 kx \fBnodateext\fR
5 kx Do not archive old versions of log files with date extension
5 kx (this overrides the \fBdateext\fR option).
5 kx
5 kx .TP
5 kx \fBdateformat\fR \fIformat_string\fR
5 kx Specify the extension for \fBdateext\fR using the notation similar to
5 kx \fBstrftime\fR(3) function. Only %Y %m %d %H %M %S %V and %s specifiers are
5 kx allowed.
5 kx The default value is \-%Y%m%d except hourly, which uses \-%Y%m%d%H as default
5 kx value. Note that also the character separating log name from the extension is
5 kx part of the dateformat string. The system clock must be set past Sep 9th 2001
5 kx for %s to work correctly.
5 kx Note that the datestamps generated by this format must be lexically sortable
5 kx (that is first the year, then the month then the day. For example 2001/12/01 is
5 kx ok, but 01/12/2001 is not, since 01/11/2002 would sort lower while it is later).
5 kx This is because when using the \fBrotate\fR option, \fBlogrotate\fR sorts all
5 kx rotated filenames to find out which logfiles are older and should be removed.
5 kx
5 kx .TP
5 kx \fBdateyesterday\fR
5 kx Use yesterday's instead of today's date to create the \fBdateext\fR
5 kx extension, so that the rotated log file has a date in its name that is
5 kx the same as the timestamps within it.
5 kx
5 kx .TP
5 kx \fBdatehourago\fR
5 kx Use hour ago instead of current date to create the \fBdateext\fR extension,
5 kx so that the rotated log file has a hour in its name that is the same as the
5 kx timestamps within it. Useful with rotate \fBhourly\fR.
5 kx
5 kx .SS Mail
5 kx
5 kx .TP
5 kx \fBmail \fIaddress\fR
5 kx When a log is rotated out of existence, it is mailed to \fIaddress\fR. If
5 kx no mail should be generated by a particular log, the \fBnomail\fR directive
5 kx may be used.
5 kx
5 kx .TP
5 kx \fBnomail\fR
5 kx Do not mail old log files to any address.
5 kx
5 kx .TP
5 kx \fBmailfirst\fR
5 kx When using the \fBmail\fR command, mail the just-rotated file,
5 kx instead of the about-to-expire file.
5 kx
5 kx .TP
5 kx \fBmaillast\fR
5 kx When using the \fBmail\fR command, mail the about-to-expire file,
5 kx instead of the just-rotated file (this is the default).
5 kx
5 kx .SS Additional config files
5 kx
5 kx .TP
5 kx \fBinclude \fIfile_or_directory\fR
5 kx Reads the file given as an argument as if it was included inline
5 kx where the \fBinclude\fR directive appears. If a directory is given,
5 kx most of the files in that directory are read in alphabetic order
5 kx before processing of the including file continues. The only files
5 kx which are ignored are files which are not regular files (such as
5 kx directories and named pipes) and files whose names end with one of
5 kx the taboo extensions or patterns, as specified by the \fBtabooext\fR
5 kx or \fBtaboopat\fR directives, respectively. The given path may
5 kx start with \fB~/\fR to make it relative to the home directory of
5 kx the executing user. For security reasons configuration files must
5 kx not be group-writable nor world-writable.
5 kx
5 kx .SS Scripts
5 kx
5 kx .TP
5 kx \fBsharedscripts\fR
5 kx Normally, \fBprerotate\fR and \fBpostrotate\fR scripts are run for each
5 kx log which is rotated and the absolute path to the log file is passed as first
5 kx argument to the script. That means a single script may be run multiple
5 kx times for log file entries which match multiple files (such as the
5 kx \fI/var/log/news/*\fR example). If \fBsharedscripts\fR is specified, the
5 kx scripts are only run once, no matter how many logs match the wildcarded pattern,
5 kx and whole pattern is passed to them.
5 kx However, if none of the logs in the pattern require rotating, the scripts
5 kx will not be run at all. If the scripts exit with error (or any log fails to
5 kx rotate), the remaining actions will not be executed for any logs. This option
5 kx overrides the \fBnosharedscripts\fR option.
5 kx
5 kx .TP
5 kx \fBnosharedscripts\fR
5 kx Run \fBprerotate\fR and \fBpostrotate\fR scripts for every log file which
5 kx is rotated (this is the default, and overrides the \fBsharedscripts\fR
5 kx option). The absolute path to the log file is passed as first argument
5 kx to the script. The absolute path to the final rotated log file is passed as
5 kx the second argument to the \fBpostrotate\fR script. If the scripts exit with
5 kx error, the remaining actions will not be executed for the affected log only.
5 kx
5 kx .tq
5 kx \fBfirstaction\fR
5 kx .tq
5 kx \ \ \ \ \fIscript\fR
5 kx .tq
5 kx \fBendscript\fR
5 kx The \fIscript\fR is executed once
5 kx before all log files that match the wildcarded pattern are rotated, before
5 kx the prerotate script is run and only if at least one log will actually be
5 kx rotated. These directives may only appear inside a log file definition.
5 kx The whole pattern is passed to the script as its first argument. If the script
5 kx exits with an error, no further processing is done. See also \fBlastaction\fR
5 kx and the \fBSCRIPTS\fR section.
5 kx
5 kx .tq
5 kx \fBlastaction\fR
5 kx .tq
5 kx \ \ \ \ \fIscript\fR
5 kx .tq
5 kx \fBendscript\fR
5 kx The \fIscript\fR is executed once
5 kx after all log files that match the wildcarded pattern are rotated, after the
5 kx postrotate script is run and only if at least one log is rotated. These
5 kx directives may only appear inside a log file definition. The whole pattern is
5 kx passed to the script as its first argument. If the script exits
5 kx with an error, just an error message is shown (as this is the last
5 kx action). See also \fBfirstaction\fR and
5 kx the \fBSCRIPTS\fR section.
5 kx
5 kx .tq
5 kx \fBprerotate\fR
5 kx .tq
5 kx \ \ \ \ \fIscript\fR
5 kx .tq
5 kx \fBendscript\fR
5 kx The \fIscript\fR is executed before
5 kx the log file is rotated and only if the log will actually be rotated. These
5 kx directives may only appear inside a log file definition. Normally,
5 kx the absolute path to the log file is passed as the first argument to the script.
5 kx If \fBsharedscripts\fR is specified, the whole pattern is passed to the script.
5 kx See also \fBpostrotate\fR and the \fBSCRIPTS\fR section.
5 kx See \fBsharedscripts\fR and \fBnosharedscripts\fR for error handling.
5 kx
5 kx .tq
5 kx \fBpostrotate\fR
5 kx .tq
5 kx \ \ \ \ \fIscript\fR
5 kx .tq
5 kx \fBendscript\fR
5 kx The \fIscript\fR is executed
5 kx after the log file is rotated. These directives may only appear inside
5 kx a log file definition. Normally, the absolute path to the log file is
5 kx passed as the first argument to the script and the absolute path to the final
5 kx rotated log file is passed as the second argument to the script. If
5 kx \fBsharedscripts\fR is specified, the whole pattern is passed as the first
5 kx argument to the script, and the second argument is omitted.
5 kx See also \fBprerotate\fR and the \fBSCRIPTS\fR section.
5 kx See \fBsharedscripts\fR and \fBnosharedscripts\fR
5 kx for error handling.
5 kx
5 kx .tq
5 kx \fBpreremove\fR
5 kx .tq
5 kx \ \ \ \ \fIscript\fR
5 kx .tq
5 kx \fBendscript\fR
5 kx The \fIscript\fR is executed
5 kx once just
5 kx before removal of a log file. \fBlogrotate\fR will pass
5 kx the name of file which is soon to be removed as the first argument to the
5 kx script. See also \fBfirstaction\fR and
5 kx the \fBSCRIPTS\fR section.
5 kx
5 kx .SH SCRIPTS
5 kx
5 kx The lines between the starting keyword (e.g. \fBprerotate\fR) and
5 kx \fBendscript\fR (both of which must appear on lines by themselves) are
5 kx executed (using \fB/bin/sh\fR).
5 kx The script inherits some traits from the \fBlogrotate\fR process, including
5 kx stderr, stdout, the current directory, the environment, and the umask.
5 kx Scripts are run as the invoking user and group, irrespective of any \fBsu\fR
5 kx directive. If the \fB\-\-log\fR flag was specified, file descriptor 3 is the
5 kx log file.
5 kx
5 kx .SH USER AND GROUP
5 kx
5 kx User and group identifiers are resolved first by trying the textual
5 kx representation and, in case it fails, afterwards by the numeric value.
5 kx
5 kx .SH FILES
5 kx
5 kx .TS
5 kx tab(:);
5 kx l l l.
5 kx \fI@STATE_FILE_PATH@\fR:Default state file.
5 kx \fI/etc/logrotate.conf\fR:Configuration options.
5 kx .TE
5 kx
5 kx
5 kx .SH "SEE ALSO"
5 kx
5 kx .BR chmod (2),
5 kx .BR gunzip (1),
5 kx .BR gzip (1),
5 kx .BR mail (1),
5 kx .BR shred (1),
5 kx .BR strftime (3),
5 kx .BR strtoul (3),
5 kx <https://github.com/logrotate/logrotate>
5 kx
5 kx .SH AUTHORS
5 kx
5 kx .nf
5 kx Erik Troan, Preston Brown, Jan Kaluza.
5 kx
5 kx <https://github.com/logrotate/logrotate>
5 kx
5 kx .fi