1SHTOOL-ROTATE.TMP(1)        GNU Portable Shell Tool       SHTOOL-ROTATE.TMP(1)
2
3
4

NAME

6       shtool rotate - GNU shtool log file rotation
7

SYNOPSIS

9       shtool rotate [-v|--verbose] [-t|--trace] [-f|--force] [-n|--num-files
10       count] [-s|--size size] [-c|--copy] [-r|--remove] [-a|--archive-dir
11       dir] [-z|--compress [tool:]level] [-b|--background] [-d|--delay]
12       [-p|--pad len] [-m|--mode mode] [-o|--owner owner] [-g|--group group]
13       [-M|--migrate cmd] [-P|--prolog cmd] [-E|--epilog cmd] file [file ...]
14

DESCRIPTION

16       This command rotates a logfile file by subsequently creating up to
17       count (optionally compressed) archive files of it. Archive files are
18       named "file.number[compress-suffix]" where number is the version
19       number, 0 being the newest and "count-1" the oldest.
20
21       A rotation step consists of the following steps
22
23       1. remove last archive file 2. shift archive file numbers 3. create
24       archive file 0 from file 4. truncate/recreate file
25

OPTIONS

27       The following command line options are available.
28
29       -v, --verbose
30           Display some processing information.
31
32       -t, --trace
33           Enable the output of the essential shell commands which are
34           executed.
35
36       -f, --force
37           Force silent creation of archive directory if it does not exists.
38           Also skip missing intermediate logfiles in the rotation step.
39           Default is to exit with error in both cases. FIXME
40
41       -n, --num-files count
42           Create count archive files. Default is 10.
43
44       -s, --size size
45           Only rotate if logfile exceeds size. The argument size can be
46           specified also with the trailing units "K" (kilo), "M" (mega) or
47           "G" (giga). The "prolog" and "epilog" are only executed if rotation
48           actually takes place.
49
50       -c, --copy
51           Copy file to archive then truncate original. The default is to move
52           file to archive.
53
54           Unless an application reopens its logfile it will continue to write
55           to the same file. In the default move case the application will
56           write to the archive which it had previously opened as file. In the
57           copy case the application will write to the original file. The
58           drawback of the copy approach is that logfile entries are lost when
59           they are written to file between the execution of the copy and the
60           truncation operation. The drawback of the move approach is that the
61           application needs to detect the move or must be triggered to reopen
62           its log (i.e.  through epilog).
63
64       -r, --remove
65           Removes file after rotation instead of providing a new empty file.
66
67       -a, --archive-dir dir
68           Specify the archive directory. Default is to create archives in the
69           same directory as file is located.
70
71       -z, --compress [tool:]level
72           Enables compression of archive files with compression level level
73           By default, the tools bzip2(1), gzip(1) and compress(1) are
74           searched for in $PATH, but one also can override this by prefixing
75           the compression level with one of the three particular tool names.
76
77       -b, --background
78           Enable background compression.
79
80       -d, --delay
81           Delays the compression of archive file number 0. This is useful if
82           ``-c'' is not used, because an application might continue to write
83           to archive file 0 through an already open file handle.
84
85       -p, --pad len
86           Enables padding with leading zeros in the number part of the
87           filename "file.numbercompress-suffix". The default padding len is
88           1.  This is interesting if more than 10 archive files are used,
89           because it leads to still sorted directory listings.
90
91       -m, --mode mode
92           The file mode applied to the created files, see chmod(1). Setting
93           mode to "-" skips this step and leaves the operating system default
94           which is usually based on umask(1). Some file modes require
95           superuser privileges to be set. Default is 0755.
96
97       -o, --owner owner
98           The file owner name or id applied to the created files, see
99           chown(1). This option requires superuser privileges to execute.
100           Default is to skip this step and leave the operating system default
101           which is usually based on the executing uid or the parent setuid
102           directory.
103
104       -g, --group group
105           The file group name or id applied to the created files, see
106           chgrp(1). This option requires superuser privileges to execute to
107           the fullest extend, otherwise the choice of group is limited on
108           most operating systems.  Default is to skip this step and leave the
109           operating system default which is usually based on the executing
110           gid or the parent setgid directory.
111
112       -M, --migrate cmd
113           Execute a "migration" command just before the archive file number
114           count-1 is removed from the filesystem. The specified cmd receives
115           the archive filename as command line argument.
116
117       -P, --prolog cmd
118           Execute a "prolog" command before the rotation step. Useful in
119           conjunction with -s.
120
121       -E, --epilog cmd
122           Execute a "epilog" command after the rotation step. Useful in
123           conjunction with -s.
124

EXAMPLE

126        #   shell script
127        shtool rotate -n10 -s1M -zbzip2:9 -d -r /var/log/ap.access.log
128        shtool rotate -n5 -s128K -zbzip2:9 -d -r /var/log/ap.error.log
129        apachectl graceful
130

HISTORY

132       The GNU shtool rotate command was originally written by Ralf S.
133       Engelschall <rse@engelschall.com> in 2001 for GNU shtool.  Its
134       development was prompted by the need to have a flexible logfile
135       rotation facility in the OpenPKG project.
136

SEE ALSO

138       shtool(1), BSD newsyslog(8).
139
140
141
14218-Jul-2008                      shtool 2.0.8             SHTOOL-ROTATE.TMP(1)
Impressum