LOGROT(1)

NAME
logrot - rotate log files

SYNOPSIS
logrot [-B preprocessor] [-c] [-C compressor] [-d destdir] [-f filter] [-F postprocessor] [-N notify_command] [-p pidfile] [-r rotatefmt] [-s sig] [-w wait] [-X compressext] file [file ...]

DESCRIPTION
logrot rotates the log file file, creating a new log file with the same permissions as the original. If necessary, the rotated file may be pre-processed with preprocessor, filtered via filter, compressed with compressor, and post-processed with postprocessor.

logrot attempts to rotate the file as atomically as possible, so that the time window in which file doesn't exist is minimised.

A signal sig can be sent to a process id stored in pidfile, or notify_command can be run to perform any other form of notification. After that, a time delay of wait seconds will occur before any filtering is performed - giving the logging process time to re-open the new logfile on receipt of the signal.

The name of the rotated file can be configured by specifying the format string rotatefmt, and the target directory is given in destdir.

OPTIONS
logrot accepts the following options (in the following list, rotfile is the name of the rotated file):

-B preprocessor
    Preprocess rotfile with preprocessor before the filtering and compression occurs, but after rotation. The % character allows for escape sequences, a la printf(3). The following escape sequences are supported: `%%' - a `%' sign. `%d' - dirname(1) of rotfile. `%f' - basename(1) of rotfile. `%p' - full pathname of rotfile.

-c  Compress data before storing in rotfile.

-C compressor
    Use compressor as the compression program for -c. Defaults to `/usr/bin/gzip'.

-d destdir
    Store rotfile in destdir. Defaults to `file.d'. If the directory does not exist, then the current directory of the logfile will be used.

-f filter
    Filter file through filter before optional compression and output to rotfile.

-F postprocessor
    Postprocess rotfile with postprocessor. Accepts the same % escape sequences as -B.

-N notify_command
    Execute notify_command instead of sending a signal. This option overrides any preceeding -s option.

-p pidfile
    Contains the pid of the process to signal with -s sig when the rotation has occurred. The first word on the first line of pidfile is assumed to be the pid. Defaults to `/var/run/syslogd.pid'. If no signal is to be sent, use -s 0.

-r rotatefmt
    Format of rotated filename, which is relative to -d destdir. Escape characters a la printf(3) are available; refer to ROTATE FORMAT ESCAPE SEQUENCES below for more information. Defaults to `%f.%y%m%d'.

-s sig
    The signal to send to the process defined in pidfile before waiting for wait seconds to expire. May be one of HUP, INT, QUIT, TERM, USR1, or USR2. Defaults to HUP. If sig is `0', then don't send a signal to pidfile. This option overrides any preceeding -N option.

-w wait
    Seconds to wait after sending the sig signal or running notify_command before performing any further processing.

-X compressext
    Extension to append to rotfile if compression occurred. Defaults to `.gz'.

  ROTATE FORMAT ESCAPE SEQUENCES
rotatefmt (as given by rotatefmt) can have escape sequences with % a la printf(3). All of the date/time escapes are generated with the same named sequence from strftime(3).

The following escape sequences are available:

%%  A `%' sign.

%f  The basename(1) of file.

%y  Current year within century (e.g, 97).

%Y  Current year, including century (e.g, 1997)

%m  Current month, with leading 0 if necessary (e.g., 02)

%d  Current day, with leading 0 if necessary (e.g., 27)

%H  Current hour (24-hour clock), with leading 0 if necessary (e.g., 23)

%M  Current minute, with leading 0 if necessary (e.g., 09)

%S  Current second, with leading 0 if necessary (e.g., 42)

DIAGNOSITICS
logrot will exit with one of the following values:

0   No error occurred.

1   An error occurred after the rotation occurred but before the filtering completed successfully. A temporary file of the form `file.logrot.XXXXXX' (where `XXXXXX' is replaced with a random number) will remain in the filesystem. This is not removed to allow manual rotation to occur.

2   An error occurred but no temporary file exists.

FILES
/var/run/syslogd.pid
    Contains the pid of the process to signal after rotation.

SEE ALSO
basename(1), dirname(1), gzip(1), signal(3), strftime(3), syslogd(8)

AUTHOR
Luke Mewburn, <luke@mewburn.net>

HISTORY
This manual page documents logrot version 1.7, released on May 30, 2005.