xref: /freebsd/usr.sbin/newsyslog/newsyslog.8 (revision daf1cffce2e07931f27c6c6998652e90df6ba87e)
1.\" This file contains changes from the Open Software Foundation.
2.\"
3.\"	from: @(#)newsyslog.8
4.\" $FreeBSD$
5.\"
6.\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
7.\"
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.
19.\"
20.Dd January 27, 1999
21.Dt NEWSYSLOG 8
22.Os
23.Sh NAME
24.Nm newsyslog
25.Nd maintain system log files to manageable sizes
26.Sh SYNOPSIS
27.Nm newsyslog
28.Op Fl Fnrv
29.Op Fl f Ar config_file
30.Sh DESCRIPTION
31.Nm Newsyslog
32is a program that should be scheduled to run periodically by
33.Xr cron 8 .
34When it is executed it archives log files if necessary.  If a log file
35is determined to require archiving,
36.Nm
37rearranges the files so that
38.Dq Va logfile
39is empty,
40.Dq Va logfile Ns Li \&.0
41has
42the last period's logs in it,
43.Dq Va logfile Ns Li \&.1
44has the next to last
45period's logs in it, and so on, up to a user-specified number of
46archived logs.  Optionally the archived logs can be compressed to save
47space.
48.Pp
49A log can be archived for three reasons:
50.Bl -enum -offset indent
51.It
52It is larger than the configured size (in kilobytes).
53.It
54A configured number of hours have elapsed since the log was last
55archived.
56.It
57This is the specific configured hour for rotation of the log.
58.El
59The granularity of
60.Nm
61is dependent on how often it is scheduled to run by
62.Xr cron 8 .
63Since the program is quite fast, it may be scheduled to run every hour
64without any ill effects,
65and mode three (above) assumes that this is so.
66.Pp
67When starting up,
68.Nm
69reads in a configuration file to determine which logs may potentially
70be archived.
71By default, this configuration file is
72.Pa /etc/newsyslog.conf .
73Each line of the file contains information about a particular log file
74that should be handled by
75.Nm Ns .
76Each line has five mandatory fields and four optional fields, with a
77whitespace separating each field.  Blank lines or lines beginning with
78``#'' are ignored.  The fields of the configuration file are as
79follows:
80.Pp
81.Bl -tag -width indent
82.It Ar logfile_name
83Name of the system log file to be archived.
84.It Ar owner:group
85This optional field specifies the owner and group for the archive file.
86The ":" is essential, even if the
87.Ar owner
88or
89.Ar group
90field is left blank.  The field may be numeric, or a name which is
91present in
92.Pa /etc/passwd
93or
94.Pa /etc/group .
95.It Ar mode
96Specify the mode of the log file and archives.
97.It Ar count
98Specify the number of archive files to be kept
99besides the log file itself.
100.It Ar size
101When the size of the log file reaches
102.Ar size
103in kilobytes,
104the log file will be trimmed as described above.  If this field
105is replaced by an asterisk
106.Pq Ql \&* ,
107then the size of the log file is not taken into account
108when determining when to trim the log file.
109.It Ar when
110The
111.Ar when
112field can consist of an interval, a specific time, or both.  If
113the
114.Ar when
115field is an asterisk
116.Pq Ql \&*
117log rotation will depend only on the contents of the
118.Ar size
119field.
120Otherwise, the
121.Ar when
122field consists of an optional interval in hours, optionally followed
123by an
124.So Li \&@ Sc Ns No -sign
125and a time in a restricted
126.Tn ISO 8601
127format.  If a time is specified, the log file will only be trimmed
128if
129.Nm
130is run within one hour of the specified time.  If an
131interval is specified, the log file will be trimmed if that many hours have
132passed since the last rotation.  When both a time and an interval are
133specified, both conditions must be satisfied for the rotation to take
134place.
135.Pp
136The particular format of the time is
137.Sm off
138.Oo
139.Oo
140.Oo
141.Oo
142.Oo
143.Va \&cc
144.Oc
145.Va \&yy
146.Oc
147.Va \&mm
148.Oc
149.Va \&dd
150.Oc
151.Oo
152.Li \&T
153.Oo
154.Va \&hh
155.Oo
156.Va \&mm
157.Oo
158.Va \&ss
159.Oc
160.Oc
161.Oc
162.Oc
163.Oc .
164.Sm on
165Optional date fields default to the appropriate component of the
166current date; optional time fields default to midnight; hence if today
167is January 22, 1999, the following date specifications are all
168equivalent:
169.Pp
170.Bl -item -compact -offset indent
171.It
172.Sq Li 19990122T000000
173.It
174.Sq Li 990122T000000
175.It
176.Sq Li 0122T000000
177.It
178.Sq Li 22T000000
179.It
180.Sq Li T000000
181.It
182.Sq Li T0000
183.It
184.Sq Li T00
185.It
186.Sq Li 22T
187.It
188.Sq Li \&T
189.It
190.Sq Li \&
191.El
192.Pp
193There is no provision for specification of a timezone.  There is
194little point in specifying an explicit minutes or seconds component in
195the current implementation, since the only comparison is `within the
196hour'.
197.It Ar flags
198This optional field specifies if the archive should have any
199special processing done to the archived log files.
200The
201.Ar Z
202flag will make the archive files compress to save space by
203using
204.Xr gzip 1 .
205The
206.Ar B
207flag means that the file is a binary file, and so the
208.Tn ASCII
209message which
210.Nm
211inserts to indicate the fact that the logs have been
212turned over should not be included.  The
213.Ar -
214flag means nothing, but can be used as a placeholder when the
215.Ar path_to_pid_file
216field is specified.
217.It Ar path_to_pid_file
218This optional field specifies
219the file name to read to find the daemon process id.  If this
220field is present, a
221.Ar signal_number
222is sent the process id contained in this
223file.  This field must start with "/" in order to be recognized
224properly.
225.It Ar signal_number
226This optional field specifies
227the signal number will be sent to the daemon process. By default
228a SIGHUP will be sent.
229.El
230.Sh OPTIONS
231The following options can be used with
232.Nm Ns :
233.Bl -tag -width indent
234.It Fl f Ar config_file
235Instruct
236.Nm
237to use
238.Ar config_file
239instead of
240.Pa /etc/newsyslog.conf
241for its configuration file.
242.It Fl v
243Place
244.Nm
245in verbose mode.  In this mode it will print out each log and its
246reasons for either trimming that log or skipping it.
247.It Fl n
248Cause
249.Nm
250not to trim the logs, but to print out what it would do if this option
251were not specified.
252.It Fl r
253Remove the restriction that
254.Nm
255must be running as root.  Of course,
256.Nm
257will not be able to send a HUP signal to
258.Xr syslogd 8
259so this option should only be used in debugging.
260.It Fl F
261Force
262.Nm
263to trim the logs, even if the trim conditions have not been met.  This
264option is useful for diagnosing system problems by providing you with
265fresh logs that contain only the problems.
266.El
267.Sh FILES
268.Bl -tag -width /etc/newsyslog.confxxxx -compact
269.It Pa /etc/newsyslog.conf
270.Nm
271configuration file
272.El
273.Sh BUGS
274Doesn't yet automatically read the logs to find security breaches.
275.Sh AUTHORS
276.An Theodore Ts'o ,
277MIT Project Athena
278.Pp
279Copyright 1987, Massachusetts Institute of Technology
280.Sh COMPATIBILITY
281Previous versions of the
282.Nm
283utility used the dot (``.'') character to
284distinguish the group name.
285Begining with
286.Fx 3.3 ,
287this has been changed to a colon (``:'') character so that user and group
288names may contain the dot character.  The dot (``.'') character is still
289accepted for backwards compatibility.
290.Sh "SEE ALSO"
291.Xr gzip 1 ,
292.Xr syslog 3 ,
293.Xr chown 8 ,
294.Xr syslogd 8
295