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