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