]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/newsyslog/newsyslog.conf.5
nvi: import version 2.2.1
[FreeBSD/FreeBSD.git] / usr.sbin / newsyslog / newsyslog.conf.5
1 .\" This file was split from the newsyslog(8) manual page by Tom Rhodes
2 .\" and includes modifications as appropriate.
3 .\" The original header is included below:
4 .\"
5 .\" This file contains changes from the Open Software Foundation.
6 .\"
7 .\"     from: @(#)newsyslog.8
8 .\"
9 .\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
10 .\"
11 .\" Permission to use, copy, modify, and distribute this software
12 .\" and its documentation for any purpose and without fee is
13 .\" hereby granted, provided that the above copyright notice
14 .\" appear in all copies and that both that copyright notice and
15 .\" this permission notice appear in supporting documentation,
16 .\" and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
17 .\" used in advertising or publicity pertaining to distribution
18 .\" of the software without specific, written prior permission.
19 .\" M.I.T. and the M.I.T. S.I.P.B. make no representations about
20 .\" the suitability of this software for any purpose.  It is
21 .\" provided "as is" without express or implied warranty.
22 .\"
23 .Dd February 26, 2021
24 .Dt NEWSYSLOG.CONF 5
25 .Os
26 .Sh NAME
27 .Nm newsyslog.conf
28 .Nd
29 .Xr newsyslog 8
30 configuration file
31 .Sh DESCRIPTION
32 The
33 .Nm
34 file is used to set log file rotation configuration for the
35 .Xr newsyslog 8
36 utility.
37 Configuration may designate that logs are rotated based on
38 size, last rotation time, or time of day.
39 The
40 .Nm
41 file can also be used to designate secure permissions to log
42 files at rotation time.
43 During initialization,
44 .Xr newsyslog 8
45 reads a configuration file,
46 normally
47 .Pa /etc/newsyslog.conf ,
48 to determine which logs may potentially be rotated and archived.
49 Each line has five mandatory fields and four optional fields,
50 separated with whitespace.
51 Blank lines or lines beginning with
52 .Ql #
53 are ignored.
54 If
55 .Ql #
56 is placed in the middle of the line, the
57 .Ql #
58 character and the rest of the line after it is ignored.
59 To prevent special meaning, the
60 .Ql #
61 character may be escaped with
62 .Ql \e ;
63 in this case preceding
64 .Ql \e
65 is removed and
66 .Ql #
67 is treated as an ordinary character.
68 The fields of the configuration file are as follows:
69 .Bl -tag -width indent
70 .It Ar logfile_name
71 Name of the system log file to be archived,
72 or one of the literal strings
73 .Dq Aq Li default ,
74 or
75 .Dq Aq Li include .
76 The special default entry will only be used if a log file
77 name is given as a command line argument to
78 .Xr newsyslog 8 ,
79 and if that log file name is not matched by any other
80 line in the configuration file.
81 The include entry is used to include other configuration
82 files and supports globbing.
83 .It Ar owner : Ns Ar group
84 This optional field specifies the owner and group for the archive file.
85 The
86 .Ql \&:
87 is essential regardless if the
88 .Ar owner
89 or
90 .Ar group
91 field is left blank or contains a value.
92 The field may be numeric, or a name which is present in
93 .Pa /etc/passwd
94 or
95 .Pa /etc/group .
96 .It Ar mode
97 Specify the file mode of the log file and archives.
98 Valid mode bits are
99 .Dv 0666 .
100 (That is, read and write permissions for the rotated log may be specified for
101 the owner, group, and others.)
102 All other mode bits are ignored.
103 .It Ar count
104 Specify the maximum number of archive files which may exist.
105 This does not consider the current log file.
106 .It Ar size
107 When the size of the log file reaches
108 .Ar size
109 in kilobytes, the log file will be trimmed as described above.
110 If this field contains an asterisk
111 .Pq Ql * ,
112 the log file will not be trimmed based on size.
113 .It Ar when
114 The
115 .Ar when
116 field may consist of an interval, a specific time, or both.
117 If the
118 .Ar when
119 field contains an asterisk
120 .Pq Ql * ,
121 log rotation will solely depend on the contents of the
122 .Ar size
123 field.
124 Otherwise, the
125 .Ar when
126 field consists of an optional interval in hours, usually followed
127 by an
128 .So Li \&@ Sc Ns No -sign
129 and a time in restricted
130 .Tn ISO 8601
131 format.
132 Additionally, the format may also be constructed with a
133 .Ql $
134 sign along with a rotation time specification of once
135 a day, once a week, or once a month.
136 .Pp
137 Time based trimming happens only if
138 .Xr newsyslog 8
139 is run within one hour of the specified time.
140 If an interval is specified, the log file will be trimmed if that many
141 hours have passed since the last rotation.
142 When both a time and an interval are
143 specified then both conditions must be satisfied for the rotation to
144 take place.
145 .Pp
146 There is no provision for the specification of a timezone.
147 There is little point in specifying an explicit minutes or
148 seconds component in the current implementation, since the only comparison is
149 .Dq within the hour .
150 .Pp
151 .Sy ISO 8601 restricted time format :
152 .Pp
153 The lead-in character for a restricted
154 .Tn ISO 8601
155 time is an
156 .Ql @
157 sign.
158 The particular format of the time in restricted
159 .Tn ISO 8601
160 is:
161 .Sm off
162 .Oo Oo Oo Oo Oo
163 .Va cc Oc
164 .Va yy Oc
165 .Va mm Oc
166 .Va dd Oc
167 .Oo
168 .Li T Oo
169 .Va hh Oo
170 .Va mm Oo
171 .Va ss
172 .Oc Oc Oc Oc Oc .
173 .Sm on
174 Optional date fields default to the appropriate component of the
175 current date; optional time fields default to midnight; hence if today
176 is January 22, 1999, the following date specifications are all
177 equivalent:
178 .Pp
179 .Bl -item -compact -offset indent
180 .It
181 .Sq Li 19990122T000000
182 .It
183 .Sq Li 990122T000000
184 .It
185 .Sq Li 0122T000000
186 .It
187 .Sq Li 22T000000
188 .It
189 .Sq Li T000000
190 .It
191 .Sq Li T0000
192 .It
193 .Sq Li T00
194 .It
195 .Sq Li 22T
196 .It
197 .Sq Li T
198 .It
199 .Sq Li \&
200 .El
201 .Pp
202 .Sy Day, week, and month time format:
203 .Pp
204 The lead-in character for day, week, and month specification is a
205 .Ql $
206 sign.
207 The particular format of day, week, and month specification is:
208 .Op Li D Ns Va hh ,
209 .Op Li W Ns Va w Ns Op Li D Ns Va hh ,
210 and
211 .Op Li M Ns Va dd Ns Op Li D Ns Va hh ,
212 respectively.
213 Optional time fields default to midnight.
214 The ranges for day and hour specifications are:
215 .Pp
216 .Bl -tag -width indent -offset indent -compact
217 .It Ar hh
218 hours, range 0..23
219 .It Ar w
220 day of week, range 0..6, 0 = Sunday
221 .It Ar dd
222 day of month, range 1..31, or one of the letters
223 .Ql L
224 or
225 .Ql l
226 to specify the last day of the month.
227 .El
228 .Pp
229 Some examples:
230 .Pp
231 .Bl -tag -width indent -offset indent -compact
232 .It Li $D0
233 rotate every night at midnight
234 (same as
235 .Li @T00 )
236 .It Li $D23
237 rotate every day at 23:00
238 (same as
239 .Li @T23 )
240 .It Li $W0D23
241 rotate every week on Sunday at 23:00
242 .It Li $W5D16
243 rotate every week on Friday at 16:00
244 .It Li $M1D0
245 rotate at the first day of every month at midnight
246 (i.e., the start of the day; same as
247 .Li @01T00 )
248 .It Li $M5D6
249 rotate on every fifth day of month at 6:00
250 (same as
251 .Li @05T06 )
252 .El
253 .It Ar flags
254 This optional field is made up of one or more characters
255 that specify any special processing to be done for the log
256 files matched by this line.
257 The following are valid flags:
258 .Bl -tag -width indent
259 .It Cm B
260 indicates that the log file is a binary file, or has some
261 special format.
262 Usually
263 .Xr newsyslog 8
264 inserts an
265 .Tn ASCII
266 message into a log file during rotation.
267 This message is used to indicate
268 when, and sometimes why the log file was rotated.
269 If
270 .Cm B
271 is specified, then that informational message will not be
272 inserted into the log file.
273 .It Cm C
274 indicates that the log file should be created if it does not
275 already exist, and if the
276 .Fl C
277 option was also specified on the command line.
278 .It Cm D
279 indicates that
280 .Xr newsyslog 8
281 should set the
282 .Dv UF_NODUMP
283 flag when creating a new version of
284 this log file.
285 This option would affect how the
286 .Xr dump 8
287 command treats the log file when making a file system backup.
288 .It Cm E
289 indicates that the log file should not be rotated when its
290 size is zero.
291 The
292 .Cm E
293 flag is mostly useful in conjunction with
294 .Cm B
295 flag to prevent
296 .Xr newsyslog 8
297 from inserting an informational 
298 .Tn ASCII
299 message into the new file.
300 .It Cm G
301 indicates that the specified
302 .Ar logfile_name
303 is a shell pattern, and that
304 .Xr newsyslog 8
305 should archive all filenames matching that pattern using the
306 other options on this line.
307 See
308 .Xr glob 3
309 for details on syntax and matching rules.
310 .It Cm J
311 indicates that
312 .Xr newsyslog 8
313 should attempt to save disk space by compressing the rotated
314 log file using
315 .Xr bzip2 1 .
316 .It Cm N
317 indicates that there is no process which needs to be signaled
318 when this log file is rotated.
319 .It Cm p
320 indicates that the zero-th rotated file should not be compressed.
321 .It Cm R
322 if this flag is set the
323 .Xr newsyslog 8
324 will run shell command defined in
325 .Ar path_to_pid_cmd_file
326 after rotation instead of trying to send signal to a process id
327 stored in the file.
328 .It Cm T
329 if this flag is set the informational rotation message written to
330 the log file will be in the format specified by RFC5424.
331 Normally, the rotation message is written in the traditional (RFC3164)
332 syslog format.
333 .It Cm U
334 indicates that the file specified by
335 .Ar path_to_pid_cmd_file
336 will contain the ID for a process group instead of a process.
337 This option also requires that the first line in that file
338 be a negative value to distinguish it from a process ID.
339 .It Cm X
340 indicates that
341 .Xr newsyslog 8
342 should attempt to save disk space by compressing the rotated
343 log file using
344 .Xr xz 1 .
345 .It Cm Y
346 indicates that
347 .Xr newsyslog 8
348 should attempt to save disk space by compressing the rotated
349 log file using
350 .Xr zstd 1 .
351 .It Cm Z
352 indicates that
353 .Xr newsyslog 8
354 should attempt to save disk space by compressing the rotated
355 log file using
356 .Xr gzip 1 .
357 .It Fl
358 a minus sign will not cause any special processing, but it
359 can be used as a placeholder to create a
360 .Ar flags
361 field when you need to specify any of the following fields.
362 .El
363 .It Ar path_to_pid_cmd_file
364 This optional field specifies the file name containing a daemon's
365 process ID or to find a group process ID if the
366 .Cm U
367 flag was specified.
368 If this field is present, a
369 .Ar signal
370 is sent to the process ID contained in this file.
371 If this field is not present and the
372 .Cm N
373 flag has not been specified, then a
374 .Dv SIGHUP
375 signal will be sent to
376 .Xr syslogd 8
377 or to the process id found in the file specified by
378 .Xr newsyslog 8 Ns 's
379 .Fl S
380 switch.
381 This field must start with
382 .Ql /
383 in order to be recognized properly.
384 When used with the
385 .Cm R
386 flag, the file is treated as a path to a binary to be executed
387 by the
388 .Xr newsyslog 8
389 after rotation instead of sending the signal out.
390 .It Ar signal
391 This optional field specifies the signal that will be sent to the daemon
392 process (or to all processes in a process group, if the
393 .Cm U
394 flag was specified).
395 If this field is not present, then a
396 .Dv SIGHUP
397 signal will be sent.
398 Signal names
399 must start with
400 .Dq SIG
401 and be the signal name, e.g.,
402 .Dv SIGUSR1 .
403 Alternatively,
404 .Ar signal
405 can be the signal number, e.g., 30 for
406 .Dv SIGUSR1 .
407 .El
408 .Sh EXAMPLES
409 The following is an example of the
410 .Dq Aq Li include
411 entry:
412 .Dl "<include> /etc/newsyslog-local.conf"
413 .Sh SEE ALSO
414 .Xr bzip2 1 ,
415 .Xr gzip 1 ,
416 .Xr xz 1 ,
417 .Xr zstd 1 ,
418 .Xr syslog 3 ,
419 .Xr chown 8 ,
420 .Xr newsyslog 8 ,
421 .Xr syslogd 8
422 .Pp
423 .Rs
424 .%A C. Lonvick
425 .%T The BSD syslog Protocol
426 .%O RFC3164
427 .Re
428 .Rs
429 .%A R. Gerhards
430 .%T The Syslog Protocol
431 .%O RFC5424
432 .Re
433 .Sh HISTORY
434 This manual page first appeared in
435 .Fx 4.10 .