.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SHTOOL-ROTATE.TMP 1" .TH SHTOOL-ROTATE.TMP 1 "shtool 2.0.8" "18-Jul-2008" "GNU Portable Shell Tool" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" shtool\-rotate \- GNU shtool log file rotation .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBshtool rotate\fR [\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-t\fR|\fB\-\-trace\fR] [\fB\-f\fR|\fB\-\-force\fR] [\fB\-n\fR|\fB\-\-num\-files\fR \fIcount\fR] [\fB\-s\fR|\fB\-\-size\fR \fIsize\fR] [\fB\-c\fR|\fB\-\-copy\fR] [\fB\-r\fR|\fB\-\-remove\fR] [\fB\-a\fR|\fB\-\-archive\-dir\fR \fIdir\fR] [\fB\-z\fR|\fB\-\-compress\fR [\fItool\fR:]\fIlevel\fR] [\fB\-b\fR|\fB\-\-background\fR] [\fB\-d\fR|\fB\-\-delay\fR] [\fB\-p\fR|\fB\-\-pad\fR \fIlen\fR] [\fB\-m\fR|\fB\-\-mode\fR \fImode\fR] [\fB\-o\fR|\fB\-\-owner\fR \fIowner\fR] [\fB\-g\fR|\fB\-\-group\fR \fIgroup\fR] [\fB\-M\fR|\fB\-\-migrate\fR \fIcmd\fR] [\fB\-P\fR|\fB\-\-prolog\fR \fIcmd\fR] [\fB\-E\fR|\fB\-\-epilog\fR \fIcmd\fR] \&\fIfile\fR [\fIfile\fR ...] .SH "DESCRIPTION" .IX Header "DESCRIPTION" This command rotates a logfile \fIfile\fR by subsequently creating up to \&\fIcount\fR (optionally compressed) archive files of it. Archive files are named "\fIfile\fR.\fInumber\fR[\fIcompress\-suffix]\fR" where \fInumber\fR is the version number, 0 being the newest and "\fIcount\fR\-1" the oldest. .PP A rotation step consists of the following steps .PP 1. remove last archive file 2. shift archive file numbers 3. create archive file 0 from \fIfile\fR 4. truncate/recreate \fIfile\fR .SH "OPTIONS" .IX Header "OPTIONS" The following command line options are available. .IP "\fB\-v\fR, \fB\-\-verbose\fR" 4 .IX Item "-v, --verbose" Display some processing information. .IP "\fB\-t\fR, \fB\-\-trace\fR" 4 .IX Item "-t, --trace" Enable the output of the essential shell commands which are executed. .IP "\fB\-f\fR, \fB\-\-force\fR" 4 .IX Item "-f, --force" Force silent creation of archive directory if it does not exists. Also skip missing intermediate logfiles in the rotation step. Default is to exit with error in both cases. \s-1FIXME\s0 .IP "\fB\-n\fR, \fB\-\-num\-files\fR \fIcount\fR" 4 .IX Item "-n, --num-files count" Create \fIcount\fR archive files. Default is 10. .IP "\fB\-s\fR, \fB\-\-size\fR \fIsize\fR" 4 .IX Item "-s, --size size" Only rotate if logfile exceeds \fIsize\fR. The argument \fIsize\fR can be specified also with the trailing units \f(CW\*(C`K\*(C'\fR (kilo), \f(CW\*(C`M\*(C'\fR (mega) or \f(CW\*(C`G\*(C'\fR (giga). The \*(L"prolog\*(R" and \*(L"epilog\*(R" are only executed if rotation actually takes place. .IP "\fB\-c\fR, \fB\-\-copy\fR" 4 .IX Item "-c, --copy" Copy \fIfile\fR to archive then truncate original. The default is to move \&\fIfile\fR to archive. .Sp Unless an application reopens its logfile it will continue to write to the same file. In the default move case the application will write to the archive which it had previously opened as \fIfile\fR. In the copy case the application will write to the original \fIfile\fR. The drawback of the copy approach is that logfile entries are lost when they are written to \fIfile\fR between the execution of the copy and the truncation operation. The drawback of the move approach is that the application needs to detect the move or must be triggered to reopen its log (i.e. through epilog). .IP "\fB\-r\fR, \fB\-\-remove\fR" 4 .IX Item "-r, --remove" Removes \fIfile\fR after rotation instead of providing a new empty file. .IP "\fB\-a\fR, \fB\-\-archive\-dir\fR \fIdir\fR" 4 .IX Item "-a, --archive-dir dir" Specify the archive directory. Default is to create archives in the same directory as \fIfile\fR is located. .IP "\fB\-z\fR, \fB\-\-compress\fR [\fItool\fR:]\fIlevel\fR" 4 .IX Item "-z, --compress [tool:]level" Enables compression of archive files with compression level \fIlevel\fR By default, the tools \fBbzip2\fR\|(1), \fBgzip\fR\|(1) and \fBcompress\fR\|(1) are searched for in \&\f(CW$PATH\fR, but one also can override this by prefixing the compression level with one of the three particular tool names. .IP "\fB\-b\fR, \fB\-\-background\fR" 4 .IX Item "-b, --background" Enable background compression. .IP "\fB\-d\fR, \fB\-\-delay\fR" 4 .IX Item "-d, --delay" Delays the compression of archive file number 0. This is useful if ``\fB\-c\fR'' is not used, because an application might continue to write to archive file 0 through an already open file handle. .IP "\fB\-p\fR, \fB\-\-pad\fR \fIlen\fR" 4 .IX Item "-p, --pad len" Enables padding with leading zeros in the \fInumber\fR part of the filename "\fIfile\fR.\fInumber\fR\fIcompress-suffix\fR". The default padding \fIlen\fR is 1. This is interesting if more than 10 archive files are used, because it leads to still sorted directory listings. .IP "\fB\-m\fR, \fB\-\-mode\fR \fImode\fR" 4 .IX Item "-m, --mode mode" The file mode applied to the created files, see \fBchmod\fR\|(1). Setting mode to \&\f(CW\*(C`\-\*(C'\fR skips this step and leaves the operating system default which is usually based on \fBumask\fR\|(1). Some file modes require superuser privileges to be set. Default is 0755. .IP "\fB\-o\fR, \fB\-\-owner\fR \fIowner\fR" 4 .IX Item "-o, --owner owner" The file owner name or id applied to the created files, see \fBchown\fR\|(1). This option requires superuser privileges to execute. Default is to skip this step and leave the operating system default which is usually based on the executing uid or the parent setuid directory. .IP "\fB\-g\fR, \fB\-\-group\fR \fIgroup\fR" 4 .IX Item "-g, --group group" The file group name or id applied to the created files, see \fBchgrp\fR\|(1). This option requires superuser privileges to execute to the fullest extend, otherwise the choice of \fIgroup\fR is limited on most operating systems. Default is to skip this step and leave the operating system default which is usually based on the executing gid or the parent setgid directory. .IP "\fB\-M\fR, \fB\-\-migrate\fR \fIcmd\fR" 4 .IX Item "-M, --migrate cmd" Execute a \*(L"migration\*(R" command just before the archive file number \&\fIcount\fR\-1 is removed from the filesystem. The specified \fIcmd\fR receives the archive filename as command line argument. .IP "\fB\-P\fR, \fB\-\-prolog\fR \fIcmd\fR" 4 .IX Item "-P, --prolog cmd" Execute a \*(L"prolog\*(R" command before the rotation step. Useful in conjunction with \fB\-s\fR. .IP "\fB\-E\fR, \fB\-\-epilog\fR \fIcmd\fR" 4 .IX Item "-E, --epilog cmd" Execute a \*(L"epilog\*(R" command after the rotation step. Useful in conjunction with \fB\-s\fR. .SH "EXAMPLE" .IX Header "EXAMPLE" .Vb 4 \& # shell script \& shtool rotate \-n10 \-s1M \-zbzip2:9 \-d \-r /var/log/ap.access.log \& shtool rotate \-n5 \-s128K \-zbzip2:9 \-d \-r /var/log/ap.error.log \& apachectl graceful .Ve .SH "HISTORY" .IX Header "HISTORY" The \fB\s-1GNU\s0 shtool\fR \fBrotate\fR command was originally written by Ralf S. Engelschall in 2001 for \fB\s-1GNU\s0 shtool\fR. Its development was prompted by the need to have a flexible logfile rotation facility in the \fBOpenPKG\fR project. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBshtool\fR\|(1), \s-1BSD\s0 \fBnewsyslog\fR\|(8).