1ROTATELOGS(8)                     rotatelogs                     ROTATELOGS(8)
2
3
4

NAME

6       rotatelogs - Piped logging program to rotate Apache logs
7
8

SYNOPSIS

10       rotatelogs [ -l ] [ -L linkname ] [ -p program ] [ -f ] [ -D ] [ -t ] [
11       -v ] [ -e ] [ -c ] [ -n number-of-files  ]  logfile  rotationtime|file‐
12       size(B|K|M|G) [ offset ]
13
14
15

SUMMARY

17       rotatelogs  is  a  simple  program for use in conjunction with Apache's
18       piped logfile feature. It supports rotation based on a time interval or
19       maximum size of the log.
20
21
22

OPTIONS

24       -l     Causes the use of local time rather than GMT as the base for the
25              interval or for strftime(3) formatting with size-based rotation.
26
27       -L linkname
28
29       -p program
30              If given, rotatelogs will execute the  specified  program  every
31              time  a new log file is opened. The filename of the newly opened
32              file is passed as the first argument to the program. If  execut‐
33              ing  after  a rotation, the old log file is passed as the second
34              argument. rotatelogs does not wait for the specified program  to
35              terminate  before  continuing  to  operate, and will not log any
36              error code returned on termination. The spawned program uses the
37              same  stdin,  stdout,  and stderr as rotatelogs itself, and also
38              inherits the environment.
39
40       -f     Causes the logfile to be opened immediately, as soon as rotatel‐
41              ogs starts, instead of waiting for the first logfile entry to be
42              read (for non-busy sites,  there  may  be  a  substantial  delay
43              between when the server is started and when the first request is
44              handled, meaning that the associated logfile  does  not  "exist"
45              until  then,  which  causes problems from some automated logging
46              tools)
47
48       -D     Creates the parent directories of the path  that  the  log  file
49              will  be  placed  in  if  they do not already exist. This allows
50              strftime(3) formatting to be used in the path and not  just  the
51              filename.
52
53       -t     Causes  the  logfile to be truncated instead of rotated. This is
54              useful when a log is processed in real time by  a  command  like
55              tail,  and there is no need for archived data. No suffix will be
56              added to the filename, however  format  strings  containing  '%'
57              characters will be respected.
58
59       -v     Produce verbose output on STDERR. The output contains the result
60              of the configuration  parsing,  and  all  file  open  and  close
61              actions.
62
63       -e     Echo logs through to stdout. Useful when logs need to be further
64              processed in real time by a further tool in the chain.
65
66       -c     Create log file for each interval, even if empty.
67
68       -n number-of-files
69              Use a circular list of filenames without timestamps. With -n  3,
70              the  series of log files opened would be "logfile", "logfile.1",
71              "logfile.2", then overwriting "logfile". Available in 2.4.5  and
72              later.
73
74       logfile
75
76       rotationtime
77              The  time  between  log  file rotations in seconds. The rotation
78              occurs at the beginning of this interval. For  example,  if  the
79              rotation  time  is  3600,  the  log  file will be rotated at the
80              beginning of every hour; if the rotation time is 86400, the  log
81              file  will  be  rotated  every night at midnight. (If no data is
82              logged during an interval, no file will be created.)
83
84       filesize(B|K|M|G)
85              The maximum file size in followed by exactly one of the  letters
86              B  (Bytes),  K (KBytes), M (MBytes) or G (GBytes). .PP When time
87              and size are specified, the size must be given after  the  time.
88              Rotation  will  occur  whenever  either  time or size limits are
89              reached.
90
91       offset The number of minutes offset  from  UTC.  If  omitted,  zero  is
92              assumed  and  UTC is used. For example, to use local time in the
93              zone UTC -5 hours, specify a value of -300 for this argument. In
94              most cases, -l should be used instead of specifying an offset.
95
96

EXAMPLES

98            CustomLog "|bin/rotatelogs /var/log/logfile 86400" common
99
100
101
102       This  creates  the files /var/log/logfile.nnnn where nnnn is the system
103       time at which the log nominally starts (this time will always be a mul‐
104       tiple  of  the  rotation time, so you can synchronize cron scripts with
105       it). At the end of each rotation time (here after 24 hours) a  new  log
106       is started.
107
108
109            CustomLog "|bin/rotatelogs -l /var/log/logfile.%Y.%m.%d 86400" common
110
111
112
113       This  creates  the  files /var/log/logfile.yyyy.mm.dd where yyyy is the
114       year, mm is the month, and dd is the day of  the  month.  Logging  will
115       switch to a new file every day at midnight, local time.
116
117
118            CustomLog "|bin/rotatelogs /var/log/logfile 5M" common
119
120
121
122       This  configuration  will rotate the logfile whenever it reaches a size
123       of 5 megabytes.
124
125
126            ErrorLog "|bin/rotatelogs /var/log/errorlog.%Y-%m-%d-%H_%M_%S 5M"
127
128
129
130       This configuration will rotate the error logfile whenever it reaches  a
131       size of 5 megabytes, and the suffix to the logfile name will be created
132       of the form errorlog.YYYY-mm-dd-HH_MM_SS.
133
134
135            CustomLog "|bin/rotatelogs -t /var/log/logfile 86400" common
136
137
138
139       This creates the file /var/log/logfile, truncating the file at  startup
140       and  then truncating the file once per day. It is expected in this sce‐
141       nario that a separate process (such as tail) would process the file  in
142       real time.
143
144

PORTABILITY

146       The  following  logfile format string substitutions should be supported
147       by all strftime(3) implementations, see the strftime(3)  man  page  for
148       library-specific extensions.
149
150
151       · %A - full weekday name (localized)
152
153
154       · %a - 3-character weekday name (localized)
155
156
157       · %B - full month name (localized)
158
159
160       · %b - 3-character month name (localized)
161
162
163       · %c - date and time (localized)
164
165
166       · %d - 2-digit day of month
167
168
169       · %H - 2-digit hour (24 hour clock)
170
171
172       · %I - 2-digit hour (12 hour clock)
173
174
175       · %j - 3-digit day of year
176
177
178       · %M - 2-digit minute
179
180
181       · %m - 2-digit month
182
183
184       · %p - am/pm of 12 hour clock (localized)
185
186
187       · %S - 2-digit second
188
189
190       · %U - 2-digit week of year (Sunday first day of week)
191
192
193       · %W - 2-digit week of year (Monday first day of week)
194
195
196       · %w - 1-digit weekday (Sunday first day of week)
197
198
199       · %X - time (localized)
200
201
202       · %x - date (localized)
203
204
205       · %Y - 4-digit year
206
207
208       · %y - 2-digit year
209
210
211       · %Z - time zone name
212
213
214       · %% - literal `%'
215
216
217
218
219Apache HTTP Server                2020-06-10                     ROTATELOGS(8)
Impressum