1 .\" This file contains changes from the Open Software Foundation.
3 .\" from: @(#)newsyslog.8
4 .\" $FreeBSD: src/usr.sbin/newsyslog/newsyslog.8,v 1.23.2.14 2003/05/07 20:42:56 gad Exp $
6 .\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
8 .\" Permission to use, copy, modify, and distribute this software
9 .\" and its documentation for any purpose and without fee is
10 .\" hereby granted, provided that the above copyright notice
11 .\" appear in all copies and that both that copyright notice and
12 .\" this permission notice appear in supporting documentation,
13 .\" and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
14 .\" used in advertising or publicity pertaining to distribution
15 .\" of the software without specific, written prior permission.
16 .\" M.I.T. and the M.I.T. S.I.P.B. make no representations about
17 .\" the suitability of this software for any purpose. It is
18 .\" provided "as is" without express or implied warranty.
25 .Nd maintain system log files to manageable sizes
31 .Op Fl f Ar config_file
36 utility should be scheduled to run periodically by
38 When it is executed it archives log files if necessary. If a log file
39 is determined to require archiving,
41 rearranges the files so that
44 .Dq Va logfile Ns Li \&.0
46 the last period's logs in it,
47 .Dq Va logfile Ns Li \&.1
49 period's logs in it, and so on, up to a user-specified number of
50 archived logs. Optionally the archived logs can be compressed to save
53 A log can be archived for three reasons:
54 .Bl -enum -offset indent
56 It is larger than the configured size (in kilobytes).
58 A configured number of hours have elapsed since the log was last
61 This is the specific configured hour for rotation of the log.
66 is dependent on how often it is scheduled to run by
68 Since the program is quite fast, it may be scheduled to run every hour
69 without any ill effects,
70 and mode three (above) assumes that this is so.
74 reads in a configuration file to determine which logs may potentially
76 By default, this configuration file is
77 .Pa /etc/newsyslog.conf .
78 Each line of the file contains information about a particular log file
79 that should be handled by
81 Each line has five mandatory fields and four optional fields, with
82 whitespace separating each field. Blank lines or lines beginning with
83 ``#'' are ignored. If ``#'' is placed in the middle of the line,
84 ``#'' character and the rest of the line after it is ignored.
85 To prevent special meaning, the ``#'' may be escaped with ``\\'',
86 in this case preceding ``\\'' is removed and ``#'' treated as ordinary
87 character. The fields of the configuration file are as
90 .Bl -tag -width indent
92 Name of the system log file to be archived, or the literal string
94 The special default entry will be only be used if some log file
95 name is given as a command line argument on the
97 command, and if that log file name is not matched by any other
98 line in the configuration file.
99 .It Ar owner : Ns Ar group
100 This optional field specifies the owner and group for the archive file.
101 The ":" is essential, even if the
105 field is left blank. The field may be numeric, or a name which is
111 Specify the mode of the log file and archives.
113 Specify the number of archive files to be kept
114 besides the log file itself.
116 When the size of the log file reaches
119 the log file will be trimmed as described above. If this field
120 is replaced by an asterisk
122 then the size of the log file is not taken into account
123 when determining when to trim the log file.
127 field can consist of an interval, a specific time, or both. If
132 log rotation will depend only on the contents of the
137 field consists of an optional interval in hours, optionally followed
139 .So Li \&@ Sc Ns No -sign
140 and a time in a restricted
143 .So Li \&$ Sc Ns No -sign
144 and a time specification for logfile rotation at a fixed time once
145 per day, per week or per month.
147 If a time is specified, the log file will only be trimmed if
149 is run within one hour of the specified time. If an
150 interval is specified, the log file will be trimmed if that many hours have
151 passed since the last rotation. When both a time and an interval are
152 specified, both conditions must be satisfied for the rotation to take
155 There is no provision for specification of a timezone. There is
156 little point in specifying an explicit minutes or seconds component in
157 the current implementation, since the only comparison is `within the
160 .Sy ISO 8601 restricted time format
162 The lead-in character for a restricted
166 .So Li \&@ Sc Ns No -sign .
167 The particular format of the time in restricted
198 Optional date fields default to the appropriate component of the
199 current date; optional time fields default to midnight; hence if today
200 is January 22, 1999, the following date specifications are all
203 .Bl -item -compact -offset indent
205 .Sq Li 19990122T000000
226 .Sy Day, week and month time format
228 The lead-in character for day, week and month specification is a
229 .So Li \&$ Sc Ns No -sign .
230 The particular format of day, week and month specification is:
232 .Op Va W\&w Ns Op Va D\&hh
234 .Op Va M\&dd Ns Op Va D\&hh
236 Optional time fields default to midnight.
237 The ranges for day and hour specifications are:
239 .Bl -tag -width Ds -compact -offset indent
241 hours, range 0 ... 23
243 day of week, range 0 ... 6, 0 = Sunday
245 day of month, range 1 ... 31, or the letter
249 to specify the last day of the month.
254 .Bl -tag -width Ds -compact -offset indent
256 rotate every night at midnight
260 rotate every day at 23:00 hr
264 rotate every week on Sunday at 23:00 hr
266 rotate every week on Friday at 16:00 hr
268 rotate at the first day of every month at midnight
269 (i.e., the start of the day; same as
272 rotate on every 5th day of month at 6:00 hr
278 This optional field is made up of one or more characters
279 that specify any special processing to be done for the log
280 files matched by this line.
281 The following are valid flags:
282 .Bl -tag -width indent
284 indicates that the log file is a binary file, or has some
290 message into a log file when rotating the file, to indicate
291 when and sometimes why the log file was rotated.
294 is specified, then that informational message will not be
295 inserted into the log file.
297 indicates that the log file should be created if it does not
298 already exist, and if the
300 option was also specified on the command line.
302 indicates that the specified
304 is a shell pattern, and that
306 should archive all filenames matching that pattern, using the
307 other options specified on this line.
310 for details on syntax and matching rules.
314 should attempt to save disk space by compressing the rotated
318 indicates that there is no process which needs to be signalled
319 when this log file is rotated.
321 indicates that the file specified by
323 will contain the id for a process group, instead of a process.
324 This option also requires that the first line in that file must
325 be a negative value, to distinguish it from a value for a
332 flag, this indicates that
334 should wait for previously started compression jobs to complete before
335 starting a new one for this entry.
336 If this is used with the
338 flag, and if multiple log files match the given pattern, then
340 will compress those logs one by one.
341 This ensures that only one compression job is running at a time.
345 should attempt to save disk space by compressing the rotated
349 a minus sign will not cause any special processing, but it
350 can be used as a placeholder to create a
352 field when you need to specify any of the following fields.
354 .It Ar path_to_pid_file
355 This optional field specifies the file name to read to find the daemon
356 process id, or to find a process group id if the
359 If this field is present, a
361 is sent the process id contained in this file.
362 If this field is not present, then a SIGHUP signal will be
367 flag has been specified.
368 This field must start with "/" in order to be recognized
371 This optional field specifies the signal number that will be sent
372 to the daemon process (or to all processes in a process group, if
376 If this field is not present, then a SIGHUP signal will be sent.
379 The following options can be used with
381 .Bl -tag -width indent
382 .It Fl f Ar config_file
388 .Pa /etc/newsyslog.conf
389 for its configuration file.
390 .It Fl a Ar directory
393 into which archived log files will be written.
394 If a relative path is given,
395 it is appended to the path of each log file
396 and the resulting path is used as the directory
397 into which the archived log for that log file will be written.
398 If an absolute path is given,
399 all archived logs are written into the given
401 If any component of the path
404 it will be created when
410 in verbose mode. In this mode it will print out each log and its
411 reasons for either trimming that log or skipping it.
415 not to trim the logs, but to print out what it would do if this option
418 Remove the restriction that
420 must be running as root. Of course,
422 will not be able to send a HUP signal to
424 so this option should only be used in debugging.
428 should not send any signals to any daemon processes that it would
429 normally signal when rotating a log file.
430 For any log file which is rotated, this option will usually also
431 mean the rotated log file will not be compressed if there is a
432 daemon which would have been signalled without this option.
433 However, this option is most likely to be useful when specified
436 option, and in that case the compression will be done.
438 If specified once, then
440 will create any log files which do not exist, and which have the
442 flag specified in their config file entry.
443 If specified multiple times, then
445 will create all log files which do not already exist.
446 If log files are given on the command-line, then the
450 will only apply to those specific log files.
454 to trim the logs, even if the trim conditions have not been met. This
455 option is useful for diagnosing system problems by providing you with
456 fresh logs that contain only the problems.
460 should rotate a given list of files, even if trim conditions are not
464 is only used in the messages written to the log files which are
466 This differs from the
468 option in that one or more log files must also be specified, so that
470 will only operate on those specific files.
471 This option is mainly intended for the daemons or programs which write
472 some log files, and want to trigger a rotate based on their own criteria.
473 With this option they can execute
475 to trigger the rotate when they want it to happen, and still give the
476 system administrator a way to specify the rules of rotation (such as how
477 many backup copies are kept, and what kind of compression is done).
478 When a daemon does execute
482 option, it should make sure all of the log files are closed before
485 and then it should re-open the files after
488 Usually the calling process will also want to specify the
492 will not send a signal to the very process which called it to force
494 Skipping the signal step will also mean that
496 will return faster, since
498 normally waits a few seconds after any signal that is sent.
501 If additional command line arguments are given,
503 will only examine log files that match those arguments; otherwise, it
504 will examine all files listed in the configuration file.
506 .Bl -tag -width /etc/newsyslog.confxxxx -compact
507 .It Pa /etc/newsyslog.conf
512 Doesn't yet automatically read the logs to find security breaches.
517 Copyright 1987, Massachusetts Institute of Technology
519 Previous versions of the
521 utility used the dot (``.'') character to
522 distinguish the group name.
525 this has been changed to a colon (``:'') character so that user and group
526 names may contain the dot character. The dot (``.'') character is still
527 accepted for backwards compatibility.