1cronolog(1m) cronolog(1m)
2
3
4
6 cronolog - write log messages to log files named according to a tem‐
7 plate
8
9
11 cronolog [OPTION]... template
12
13
15 cronolog is a simple program that reads log messages from its input and
16 writes them to a set of output files, the names of which are con‐
17 structed using template and the current date and time. The template
18 uses the same format specifiers as the Unix date(1) command (which are
19 the same as the standard C strftime library function).
20
21 Before writing a message cronolog checks the time to see whether the
22 current log file is still valid and if not it closes the current file,
23 expands the template using the current date and time to generate a new
24 file name, opens the new file (creating missing directories on the path
25 of the new log file as needed unless the program is compiled with
26 -DDONT_CREATE_SUBDIRS) and calculates the time at which the new file
27 will become invalid.
28
29 cronolog is intended to be used in conjunction with a Web server, such
30 as Apache to split the access log into daily or monthly logs. For
31 example the Apache configuration directives:
32
33 TransferLog "|/usr/sbin/cronolog /www/logs/%Y/%m/%d/access.log"
34 ErrorLog "|/usr/sbin/cronolog /www/logs/%Y/%m/%d/errors.log"
35
36 would instruct Apache to pipe its access and error log messages into
37 separate copies of cronolog, which would create new log files each day
38 in a directory hierarchy structured by date, i.e. on 31 December 1996
39 messages would be written to
40
41 /www/logs/1996/12/31/access.log
42 /www/logs/1996/12/31/errors.log
43
44 after midnight the files
45
46 /www/logs/1997/01/01/access.log
47 /www/logs/1997/01/01/errors.log
48
49 would be used, with the directories 1997, 1997/01 and 1997/01/01 being
50 created if they did not already exist. (Note that prior to version 1.2
51 Apache did not allow a program to be specified as the argument of the
52 ErrorLog directive.)
53
54
56 accepts the following options and arguments:
57
58 -H NAME
59
60 --hardlink=NAME
61 maintain a hard link from NAME to the current log file.
62
63 -S NAME
64
65 --symlink=NAME
66
67 -l NAME
68
69 --link=NAME
70 maintain a symbolic link from NAME to the current log file.
71
72 -P NAME
73
74 --prevlink=NAME
75 maintain a symbolic link from NAME to the previous log file.
76 Requires that the --symlink option is specified, as cronolog
77 renames the current link to the name specified for the previous
78 link.
79
80 -h
81
82 --help print a help message and then exit.
83
84 -p PERIOD
85
86 --period=PERIOD
87 specifies the period explicitly as an optional digit string fol‐
88 lowed by one of units: seconds, minutes, hours, days, weeks or
89 months. The count cannot be greater than the number of units in
90 the next larger unit, i.e. you cannot specify "120 minutes", and
91 for seconds, minutes and hours the count must be a factor of the
92 next higher unit, i.e you can specify 1, 2, 3, 4, 5, 6, 10, 15,
93 20 or 30 minutes but not say 7 minutes.
94
95 -d PERIOD
96
97 --delay=PERIOD
98 specifies the delay from the start of the period before the log
99 file is rolled over. For example specifying (explicitly or
100 implicitly) a period of 15 minutes and a delay of 5 minutes
101 results in the log files being rotated at five past, twenty
102 past, twentyfive to and ten to each hour. The delay cannot be
103 longer than the period.
104
105 -o
106
107 --once-only
108 create single output log from template, which is not rotated.
109
110 -x FILE
111
112 --debug=FILE
113 write debug messages to FILE or to the standard error stream if
114 FILE is "-". (See the README file for more details.)
115
116 -s TIME
117
118 --start-time=TIME
119 pretend that the starting time is TIME (for debugging purposes).
120 TIME should be something like DD MONTH YYYY HH:MM:SS (the day
121 and month are reversed if the american option is specified). If
122 the seconds are omitted then they are taken as zero and if the
123 hours and minutes are omitted then the time of day is taken as
124 00:00:00 (i.e. midnight). The day, month and year can be sepa‐
125 rated by spaces, hyphens (-) or solidi (/).
126
127 -a
128
129 --american
130 Interprete the date part of the starting time the American way
131 (month then day).
132
133 -e
134
135 --european
136 Interprete the date part of the starting time the European way
137 (day then month). This is the default.
138
139 -v
140
141 --version
142 print version information and exit.
143
145 Each character in the template represents a character in the expanded
146 filename, except for date and time format specifiers, which are
147 replaced by their expansion. Format specifiers consist of a `%' fol‐
148 lowed by one of the following characters:
149
150 % a literal % character
151
152 n a new-line character
153
154 t a horizontal tab character
155
156 Time fields:
157
158 H hour (00..23)
159
160 I hour (01..12)
161
162 p the locale's AM or PM indicator
163
164 M minute (00..59)
165
166 S second (00..61, which allows for leap seconds)
167
168 X the locale's time representation (e.g.: "15:12:47")
169
170 Z time zone (e.g. GMT), or nothing if the time zone cannot be
171 determined
172
173 Date fields:
174
175 a the locale's abbreviated weekday name (e.g.: Sun..Sat)
176
177 A the locale's full weekday name (e.g.: Sunday .. Saturday)
178
179 b the locale's abbreviated month name (e.g.: Jan .. Dec)
180
181 B the locale's full month name, (e.g.: January .. December)
182
183 c the locale's date and time (e.g.: "Sun Dec 15 14:12:47 GMT
184 1996")
185
186 d day of month (01 .. 31)
187
188 j day of year (001 .. 366)
189
190 m month (01 .. 12)
191
192 U week of the year with Sunday as first day of week (00..53, where
193 week 1 is the week containing the first Sunday of the year)
194
195 W week of the year with Monday as first day of week (00..53, where
196 week 1 is the week containing the first Monday of the year)
197
198 w day of week (0 .. 6, where 0 corresponds to Sunday)
199
200 x locale's date representation (e.g. today in April in Britain:
201 "13/04/97")
202
203 y year without the century (00 .. 99)
204
205 Y year with the century (1970 .. 2038)
206
207 Other specifiers may be available depending on the C library's imple‐
208 mentation of the strftime function.
209
211 apache(1m) date(1) strftime(3) environ(5)
212
213 More information and the latest version of cronolog can be obtained
214 from
215
216 http://www.ford-mason.co.uk/resources/cronolog/
217
218 If you have any suggestions, bug reports, fixes, or enhancements,
219 please mail them to the author.
220
221 More about Apache
222 Documentation for the Apache http server is available from
223
224 http://www.apache.org
225
227 The functionality of cronolog could be built into Apache, thus saving
228 the overhead of having a process per log stream and that of transfer‐
229 ring data from the server process to the cronolog process. The main
230 complication is handling the case where multiple log streams are writ‐
231 ten to the same file (template), for example where different virtual
232 servers write to the same set of log files.
233
235 Andrew Ford <A.Ford@ford-mason.co.uk>
236
237 cronolog is based on a program called rotatelogs by Ben Laurie, which
238 is packaged with the Apache web server.
239
240 The symbolic link option was suggested by Juergen Lesny.
241
242
243
244 March 1998 cronolog(1m)