1ROTATELOGS(8) rotatelogs ROTATELOGS(8)
2
3
4
6 rotatelogs - Piped logging program to rotate Apache logs
7
8
10 rotatelogs [ -l ] [ -L linkname ] [ -p program ] [ -f ] [ -v ] [ -e ] [
11 -c ] [ -n number-of-files ] logfile rotationtime|filesize(B|K|M|G) [
12 offset ]
13
14
15
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
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 Causes a hard link to be made from the current logfile to the
29 specified link name. This can be used to watch the log continu‐
30 ously across rotations using a command like tail -F linkname.
31
32 -p program
33 If given, rotatelogs will execute the specified program every
34 time a new log file is opened. The filename of the newly opened
35 file is passed as the first argument to the program. If execut‐
36 ing after a rotation, the old log file is passed as the second
37 argument. rotatelogs does not wait for the specified program to
38 terminate before continuing to operate, and will not log any
39 error code returned on termination. The spawned program uses the
40 same stdin, stdout, and stderr as rotatelogs itself, and also
41 inherits the environment.
42
43 -f Causes the logfile to be opened immediately, as soon as rotatel‐
44 ogs starts, instead of waiting for the first logfile entry to be
45 read (for non-busy sites, there may be a substantial delay
46 between when the server is started and when the first request is
47 handled, meaning that the associated logfile does not "exist"
48 until then, which causes problems from some automated logging
49 tools)
50
51 -t Causes the logfile to be truncated instead of rotated. This is
52 useful when a log is processed in real time by a command like
53 tail, and there is no need for archived data. No suffix will be
54 added to the filename, however format strings containing '%'
55 characters will be respected.
56
57 -v Produce verbose output on STDERR. The output contains the result
58 of the configuration parsing, and all file open and close
59 actions.
60
61 -e Echo logs through to stdout. Useful when logs need to be further
62 processed in real time by a further tool in the chain.
63
64 -c Create log file for each interval, even if empty.
65
66 -n number-of-files
67 Use a circular list of filenames without timestamps. With -n 3,
68 the series of log files opened would be "logfile", "logfile.1",
69 "logfile.2", then overwriting "logfile".
70
71 logfile
72
73 rotationtime
74 The time between log file rotations in seconds. The rotation
75 occurs at the beginning of this interval. For example, if the
76 rotation time is 3600, the log file will be rotated at the
77 beginning of every hour; if the rotation time is 86400, the log
78 file will be rotated every night at midnight. (If no data is
79 logged during an interval, no file will be created.)
80
81 filesize(B|K|M|G)
82 The maximum file size in followed by exactly one of the letters
83 B (Bytes), K (KBytes), M (MBytes) or G (GBytes). .PP When time
84 and size are specified, the size must be given after the time.
85 Rotation will occur whenever either time or size limits are
86 reached.
87
88 offset The number of minutes offset from UTC. If omitted, zero is
89 assumed and UTC is used. For example, to use local time in the
90 zone UTC -5 hours, specify a value of -300 for this argument. In
91 most cases, -l should be used instead of specifying an offset.
92
93
95 CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common
96
97
98
99 This creates the files /var/logs/logfile.nnnn where nnnn is the system
100 time at which the log nominally starts (this time will always be a mul‐
101 tiple of the rotation time, so you can synchronize cron scripts with
102 it). At the end of each rotation time (here after 24 hours) a new log
103 is started.
104
105
106 CustomLog "|bin/rotatelogs -l /var/logs/logfile.%Y.%m.%d 86400" common
107
108
109
110 This creates the files /var/logs/logfile.yyyy.mm.dd where yyyy is the
111 year, mm is the month, and dd is the day of the month. Logging will
112 switch to a new file every day at midnight, local time.
113
114
115 CustomLog "|bin/rotatelogs /var/logs/logfile 5M" common
116
117
118
119 This configuration will rotate the logfile whenever it reaches a size
120 of 5 megabytes.
121
122
123 ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"
124
125
126
127 This configuration will rotate the error logfile whenever it reaches a
128 size of 5 megabytes, and the suffix to the logfile name will be created
129 of the form errorlog.YYYY-mm-dd-HH_MM_SS.
130
131
132 CustomLog "|bin/rotatelogs -t /var/logs/logfile 86400" common
133
134
135
136 This creates the file /var/logs/logfile, truncating the file at startup
137 and then truncating the file once per day. It is expected in this sce‐
138 nario that a separate process (such as tail) would process the file in
139 real time.
140
141
143 The following logfile format string substitutions should be supported
144 by all strftime(3) implementations, see the strftime(3) man page for
145 library-specific extensions.
146
147
148 · %A - full weekday name (localized)
149
150
151 · %a - 3-character weekday name (localized)
152
153
154 · %B - full month name (localized)
155
156
157 · %b - 3-character month name (localized)
158
159
160 · %c - date and time (localized)
161
162
163 · %d - 2-digit day of month
164
165
166 · %H - 2-digit hour (24 hour clock)
167
168
169 · %I - 2-digit hour (12 hour clock)
170
171
172 · %j - 3-digit day of year
173
174
175 · %M - 2-digit minute
176
177
178 · %m - 2-digit month
179
180
181 · %p - am/pm of 12 hour clock (localized)
182
183
184 · %S - 2-digit second
185
186
187 · %U - 2-digit week of year (Sunday first day of week)
188
189
190 · %W - 2-digit week of year (Monday first day of week)
191
192
193 · %w - 1-digit weekday (Sunday first day of week)
194
195
196 · %X - time (localized)
197
198
199 · %x - date (localized)
200
201
202 · %Y - 4-digit year
203
204
205 · %y - 2-digit year
206
207
208 · %Z - time zone name
209
210
211 · %% - literal `%'
212
213
214
215
216Apache HTTP Server 2013-06-13 ROTATELOGS(8)