1ROTATELOGS(8) rotatelogs ROTATELOGS(8)
2
3
4
6 rotatelogs - Piped logging program to rotate Apache logs
7
8
10 rotatelogs [ -l ] logfile rotationtime|filesizeM [ offset ]
11
12
13
15 rotatelogs is a simple program for use in conjunction with Apache's
16 piped logfile feature. It supports rotation based on a time interval or
17 maximum size of the log.
18
19
20
22 -l Causes the use of local time rather than GMT as the base for the
23 interval or for strftime(3) formatting with size-based rotation.
24 Note that using -l in an environment which changes the GMT off‐
25 set (such as for BST or DST) can lead to unpredictable results!
26
27 logfile
28 The path plus basename of the logfile. If logfile includes any
29 '%' characters, it is treated as a format string for strf‐
30 time(3). Otherwise, the suffix .nnnnnnnnnn is automatically
31 added and is the time in seconds. Both formats compute the start
32 time from the beginning of the current period. For example, if a
33 rotation time of 86400 is specified, the hour, minute, and sec‐
34 ond fields created from the strftime(3) format will all be zero,
35 referring to the beginning of the current 24-hour period (mid‐
36 night).
37
38 rotationtime
39 The time between log file rotations in seconds. The rotation
40 occurs at the beginning of this interval. For example, if the
41 rotation time is 3600, the log file will be rotated at the
42 beginning of every hour; if the rotation time is 86400, the log
43 file will be rotated every night at midnight. (If no data is
44 logged during an interval, no file will be created.)
45
46 filesizeM
47 The maximum file size in megabytes followed by the letter M to
48 specify size rather than time.
49
50 offset The number of minutes offset from UTC. If omitted, zero is
51 assumed and UTC is used. For example, to use local time in the
52 zone UTC -5 hours, specify a value of -300 for this argument. In
53 most cases, -l should be used instead of specifying an offset.
54
55
57 CustomLog "|bin/rotatelogs /var/logs/logfile 86400" common
58
59
60
61 This creates the files /var/logs/logfile.nnnn where nnnn is the system
62 time at which the log nominally starts (this time will always be a mul‐
63 tiple of the rotation time, so you can synchronize cron scripts with
64 it). At the end of each rotation time (here after 24 hours) a new log
65 is started.
66
67
68 CustomLog "|bin/rotatelogs -l /var/logs/logfile.%Y.%m.%d 86400" common
69
70
71
72 This creates the files /var/logs/logfile.yyyy.mm.dd where yyyy is the
73 year, mm is the month, and dd is the day of the month. Logging will
74 switch to a new file every day at midnight, local time.
75
76
77 CustomLog "|bin/rotatelogs /var/logs/logfile 5M" common
78
79
80
81 This configuration will rotate the logfile whenever it reaches a size
82 of 5 megabytes.
83
84
85 ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M"
86
87
88
89 This configuration will rotate the error logfile whenever it reaches a
90 size of 5 megabytes, and the suffix to the logfile name will be created
91 of the form errorlog.YYYY-mm-dd-HH_MM_SS.
92
93
95 The following logfile format string substitutions should be supported
96 by all strftime(3) implementations, see the strftime(3) man page for
97 library-specific extensions.
98
99
100 · %A - full weekday name (localized)
101
102
103 · %a - 3-character weekday name (localized)
104
105
106 · %B - full month name (localized)
107
108
109 · %b - 3-character month name (localized)
110
111
112 · %c - date and time (localized)
113
114
115 · %d - 2-digit day of month
116
117
118 · %H - 2-digit hour (24 hour clock)
119
120
121 · %I - 2-digit hour (12 hour clock)
122
123
124 · %j - 3-digit day of year
125
126
127 · %M - 2-digit minute
128
129
130 · %m - 2-digit month
131
132
133 · %p - am/pm of 12 hour clock (localized)
134
135
136 · %S - 2-digit second
137
138
139 · %U - 2-digit week of year (Sunday first day of week)
140
141
142 · %W - 2-digit week of year (Monday first day of week)
143
144
145 · %w - 1-digit weekday (Sunday first day of week)
146
147
148 · %X - time (localized)
149
150
151 · %x - date (localized)
152
153
154 · %Y - 4-digit year
155
156
157 · %y - 2-digit year
158
159
160 · %Z - time zone name
161
162
163 · %% - literal `%'
164
165
166
167
168Apache HTTP Server 2007-12-09 ROTATELOGS(8)