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