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 er‐
36              ror 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  be‐
43              tween  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  ac‐
61              tions.
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. This option
70              overwrites  log files at startup and during rotation. With -n 3,
71              the series of log files opened would be "logfile",  "logfile.1",
72              "logfile.2", then overwriting "logfile". When this program first
73              opens "logfile", the file will only be truncated if -t  is  also
74              provided. Every subsequent rotation will always begin with trun‐
75              cation of the target file. For size based  rotation  without  -t
76              and existing log files in place, this option may result in unin‐
77              tuitive behavior such as initial log entries being sent to "log‐
78              file.1",  and entries in "logfile.1" not being preserved even if
79              later "logfile.n" have not yet been used. Available in 2.4.5 and
80              later.
81
82       logfile
83
84       rotationtime
85              The time between log file rotations in seconds. The rotation oc‐
86              curs at the beginning of this interval. For example, if the  ro‐
87              tation  time is 3600, the log file will be rotated at the begin‐
88              ning of every hour; if the rotation time is 86400, the log  file
89              will  be  rotated every night at midnight. (If no data is logged
90              during an interval, no file will be created.)
91
92       filesize(B|K|M|G)
93              The maximum file size in followed by exactly one of the  letters
94              B  (Bytes),  K (KBytes), M (MBytes) or G (GBytes). .PP When time
95              and size are specified, the size must be given after  the  time.
96              Rotation  will  occur  whenever  either  time or size limits are
97              reached.
98
99       offset The number of minutes offset from UTC. If omitted, zero  is  as‐
100              sumed  and  UTC  is  used. For example, to use local time in the
101              zone UTC -5 hours, specify a value of -300 for this argument. In
102              most cases, -l should be used instead of specifying an offset.
103
104

EXAMPLES

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

PORTABILITY

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