xref: /freebsd/usr.sbin/newsyslog/newsyslog.8 (revision a35d88931c87cfe6bd38f01d7bad22140b3b38f3)
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 March 10, 2004
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
28.Op Fl CFnrsv
29.Op Fl R Ar tagname
30.Op Fl a Ar directory
31.Op Fl d Ar directory
32.Op Fl f Ar config_file
33.Op Ar
34.Sh DESCRIPTION
35The
36.Nm
37utility should be scheduled to run periodically by
38.Xr cron 8 .
39When it is executed it archives log files if necessary.
40If a log file
41is determined to require archiving,
42.Nm
43rearranges the files so that
44.Dq Va logfile
45is empty,
46.Dq Va logfile Ns Li \&.0
47has
48the last period's logs in it,
49.Dq Va logfile Ns Li \&.1
50has the next to last
51period's logs in it, and so on, up to a user-specified number of
52archived logs.
53Optionally the archived logs can be compressed to save
54space.
55.Pp
56A log can be archived for three reasons:
57.Bl -enum -offset indent
58.It
59It is larger than the configured size (in kilobytes).
60.It
61A configured number of hours have elapsed since the log was last
62archived.
63.It
64This is the specific configured hour for rotation of the log.
65.El
66.Pp
67The granularity of
68.Nm
69is dependent on how often it is scheduled to run by
70.Xr cron 8 .
71Since the program is quite fast, it may be scheduled to run every hour
72without any ill effects,
73and mode three (above) assumes that this is so.
74.Sh OPTIONS
75The following options can be used with
76.Nm :
77.Bl -tag -width indent
78.It Fl f Ar config_file
79Instruct
80.Nm
81to use
82.Ar config_file
83instead of
84.Pa /etc/newsyslog.conf
85for its configuration file.
86.It Fl a Ar directory
87Specify a
88.Ar directory
89into which archived log files will be written.
90If a relative path is given,
91it is appended to the path of each log file
92and the resulting path is used as the directory
93into which the archived log for that log file will be written.
94If an absolute path is given,
95all archived logs are written into the given
96.Ar directory .
97If any component of the path
98.Ar directory
99does not exist,
100it will be created when
101.Nm
102is run.
103.It Fl d Ar directory
104Specify a
105.Ar directory
106which all log files will be relative to.
107To allow archiving of logs outside the root, the
108.Ar directory
109passed to the
110.Fl a
111option is unaffected.
112.It Fl v
113Place
114.Nm
115in verbose mode.
116In this mode it will print out each log and its
117reasons for either trimming that log or skipping it.
118.It Fl n
119Cause
120.Nm
121not to trim the logs, but to print out what it would do if this option
122were not specified.
123.It Fl r
124Remove the restriction that
125.Nm
126must be running as root.
127Of course,
128.Nm
129will not be able to send a HUP signal to
130.Xr syslogd 8
131so this option should only be used in debugging.
132.It Fl s
133Specify that
134.Nm
135should not send any signals to any daemon processes that it would
136normally signal when rotating a log file.
137For any log file which is rotated, this option will usually also
138mean the rotated log file will not be compressed if there is a
139daemon which would have been signalled without this option.
140However, this option is most likely to be useful when specified
141with the
142.Fl R
143option, and in that case the compression will be done.
144.It Fl C
145If specified once, then
146.Nm
147will create any log files which do not exist, and which have the
148.Sy C
149flag specified in their config file entry.
150If specified multiple times, then
151.Nm
152will create all log files which do not already exist.
153If log files are given on the command-line, then the
154.Fl C
155or
156.Fl CC
157will only apply to those specific log files.
158.It Fl F
159Force
160.Nm
161to trim the logs, even if the trim conditions have not been met.
162This
163option is useful for diagnosing system problems by providing you with
164fresh logs that contain only the problems.
165.It Fl R Ar tagname
166Specify that
167.Nm
168should rotate a given list of files, even if trim conditions are not
169met for those files.
170The
171.Ar tagname
172is only used in the messages written to the log files which are
173rotated.
174This differs from the
175.Fl F
176option in that one or more log files must also be specified, so that
177.Nm
178will only operate on those specific files.
179This option is mainly intended for the daemons or programs which write
180some log files, and want to trigger a rotate based on their own criteria.
181With this option they can execute
182.Nm
183to trigger the rotate when they want it to happen, and still give the
184system administrator a way to specify the rules of rotation (such as how
185many backup copies are kept, and what kind of compression is done).
186When a daemon does execute
187.Nm
188with the
189.Fl R
190option, it should make sure all of the log files are closed before
191calling
192.Nm ,
193and then it should re-open the files after
194.Nm
195returns.
196Usually the calling process will also want to specify the
197.Fl s
198option, so
199.Nm
200will not send a signal to the very process which called it to force
201the rotate.
202Skipping the signal step will also mean that
203.Nm
204will return faster, since
205.Nm
206normally waits a few seconds after any signal that is sent.
207.El
208.Pp
209If additional command line arguments are given,
210.Nm
211will only examine log files that match those arguments; otherwise, it
212will examine all files listed in the configuration file.
213.Sh FILES
214.Bl -tag -width /etc/newsyslog.confxxxx -compact
215.It Pa /etc/newsyslog.conf
216.Nm
217configuration file
218.El
219.Sh BUGS
220Doesn't yet automatically read the logs to find security breaches.
221.Sh AUTHORS
222.An Theodore Ts'o ,
223MIT Project Athena
224.Pp
225Copyright 1987, Massachusetts Institute of Technology
226.Sh COMPATIBILITY
227Previous versions of the
228.Nm
229utility used the dot (``.'') character to
230distinguish the group name.
231Beginning with
232.Fx 3.3 ,
233this has been changed to a colon (``:'') character so that user and group
234names may contain the dot character.
235The dot (``.'') character is still
236accepted for backwards compatibility.
237.Sh "SEE ALSO"
238.Xr bzip 1 ,
239.Xr gzip 1 ,
240.Xr syslog 3 ,
241.Xr newsyslog.conf 5 ,
242.Xr chown 8 ,
243.Xr syslogd 8
244