]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - usr.sbin/newsyslog/newsyslog.8
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.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 January 19, 2010
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 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 P
173 Prevent further action if we should send signal but the
174 .Dq pidfile
175 is empty or does not exist.
176 .It Fl R Ar tagname
177 Specify that
178 .Nm
179 should rotate a given list of files, even if trim conditions are not
180 met for those files.
181 The
182 .Ar tagname
183 is only used in the messages written to the log files which are
184 rotated.
185 This differs from the
186 .Fl F
187 option in that one or more log files must also be specified, so that
188 .Nm
189 will only operate on those specific files.
190 This option is mainly intended for the daemons or programs which write
191 some log files, and want to trigger a rotate based on their own criteria.
192 With this option they can execute
193 .Nm
194 to trigger the rotate when they want it to happen, and still give the
195 system administrator a way to specify the rules of rotation (such as how
196 many backup copies are kept, and what kind of compression is done).
197 When a daemon does execute
198 .Nm
199 with the
200 .Fl R
201 option, it should make sure all of the log files are closed before
202 calling
203 .Nm ,
204 and then it should re-open the files after
205 .Nm
206 returns.
207 Usually the calling process will also want to specify the
208 .Fl s
209 option, so
210 .Nm
211 will not send a signal to the very process which called it to force
212 the rotate.
213 Skipping the signal step will also mean that
214 .Nm
215 will return faster, since
216 .Nm
217 normally waits a few seconds after any signal that is sent.
218 .El
219 .Pp
220 If additional command line arguments are given,
221 .Nm
222 will only examine log files that match those arguments; otherwise, it
223 will examine all files listed in the configuration file.
224 .Sh FILES
225 .Bl -tag -width /etc/newsyslog.confxxxx -compact
226 .It Pa /etc/newsyslog.conf
227 .Nm
228 configuration file
229 .El
230 .Sh COMPATIBILITY
231 Previous versions of the
232 .Nm
233 utility used the dot (``.'') character to
234 distinguish the group name.
235 Beginning with
236 .Fx 3.3 ,
237 this has been changed to a colon (``:'') character so that user and group
238 names may contain the dot character.
239 The dot (``.'') character is still
240 accepted for backwards compatibility.
241 .Sh HISTORY
242 The
243 .Nm
244 utility originated from
245 .Nx
246 and first appeared in
247 .Fx 2.2 .
248 .Sh AUTHORS
249 .An Theodore Ts'o ,
250 MIT Project Athena
251 .Pp
252 Copyright 1987, Massachusetts Institute of Technology
253 .Sh "SEE ALSO"
254 .Xr bzip2 1 ,
255 .Xr gzip 1 ,
256 .Xr syslog 3 ,
257 .Xr newsyslog.conf 5 ,
258 .Xr chown 8 ,
259 .Xr syslogd 8
260 .Sh BUGS
261 Does not yet automatically read the logs to find security breaches.