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