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