[BACK]Return to newsyslog.8 CVS log [TXT][DIR] Up to [local] / src / usr.bin / newsyslog

Annotation of src/usr.bin/newsyslog/newsyslog.8, Revision 1.38

1.38    ! millert     1: .\"    $OpenBSD: newsyslog.8,v 1.37 2004/01/23 23:08:47 jmc Exp $
1.4       downsj      2: .\"
                      3: .\" Copyright (c) 1997, Jason Downs.  All rights reserved.
                      4: .\"
                      5: .\" Redistribution and use in source and binary forms, with or without
                      6: .\" modification, are permitted provided that the following conditions
                      7: .\" are met:
                      8: .\" 1. Redistributions of source code must retain the above copyright
                      9: .\"    notice, this list of conditions and the following disclaimer.
                     10: .\" 2. Redistributions in binary form must reproduce the above copyright
                     11: .\"    notice, this list of conditions and the following disclaimer in the
                     12: .\"    documentation and/or other materials provided with the distribution.
                     13: .\"
                     14: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
                     15: .\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     16: .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     17: .\" DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
                     18: .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
                     19: .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     20: .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
                     21: .\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     22: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     23: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     24: .\" SUCH DAMAGE.
                     25: .\"
1.1       deraadt    26: .\" This file contains changes from the Open Software Foundation.
                     27: .\"
                     28: .\"    from: @(#)newsyslog.8
                     29: .\"
                     30: .\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
1.13      aaron      31: .\"
1.1       deraadt    32: .\" Permission to use, copy, modify, and distribute this software
                     33: .\" and its documentation for any purpose and without fee is
                     34: .\" hereby granted, provided that the above copyright notice
                     35: .\" appear in all copies and that both that copyright notice and
                     36: .\" this permission notice appear in supporting documentation,
                     37: .\" and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
                     38: .\" used in advertising or publicity pertaining to distribution
                     39: .\" of the software without specific, written prior permission.
                     40: .\" M.I.T. and the M.I.T. S.I.P.B. make no representations about
                     41: .\" the suitability of this software for any purpose.  It is
                     42: .\" provided "as is" without express or implied warranty.
                     43: .\"
1.31      millert    44: .Dd January 24, 2003
1.4       downsj     45: .Dt NEWSYSLOG 8
1.12      aaron      46: .Os
1.4       downsj     47: .Sh NAME
                     48: .Nm newsyslog
1.34      millert    49: .Nd trim log files to manageable sizes
1.4       downsj     50: .Sh SYNOPSIS
1.10      aaron      51: .Nm newsyslog
1.27      millert    52: .Op Fl Fmnrv
1.26      millert    53: .Op Fl a Ar directory
1.20      aaron      54: .Op Fl f Ar config_file
1.28      millert    55: .Op Ar log ...
1.4       downsj     56: .Sh DESCRIPTION
1.13      aaron      57: .Nm
1.1       deraadt    58: is a program that should be scheduled to run periodically by
1.4       downsj     59: .Xr cron 8 .
1.18      aaron      60: When it is executed it archives log files if necessary.
                     61: If a log file is determined to require archiving,
1.13      aaron      62: .Nm
                     63: rearranges the files so that
                     64: .Pa logfile
                     65: is empty,
                     66: .Pa logfile.0
                     67: has
                     68: the last period's logs in it,
                     69: .Pa logfile.1
                     70: has the next to last
1.1       deraadt    71: period's logs in it, and so on, up to a user-specified number of
1.18      aaron      72: archived logs.
1.33      millert    73: The archived logs may be optionally compressed to save space.
1.4       downsj     74: .Pp
1.18      aaron      75: The options are as follows:
                     76: .Bl -tag -width Ds
1.27      millert    77: .It Fl F
                     78: Force
                     79: .Nm
                     80: to trim logs regardless of the size and/or age requirements specified in
                     81: .Pa /etc/newsyslog.conf .
                     82: This option may be combined with the
                     83: .Fl n
                     84: or
                     85: .Fl v
                     86: flags to aid in debugging problems with
                     87: .Pa /etc/newsyslog.conf .
1.20      aaron      88: .It Fl m
                     89: Monitoring mode; only entries marked with an
                     90: .Sq M
1.31      millert    91: in flags are processed.
1.36      jmc        92: For each log file being monitored, any log output since the last time
1.31      millert    93: .Nm
                     94: was run with the
                     95: .Fl m
                     96: flag is mailed to the user listed in the monitor notification section.
1.18      aaron      97: .It Fl n
                     98: Do not trim the logs, but instead print out what would be done if this option
                     99: were not specified.
                    100: .It Fl r
                    101: Removes the restriction that
                    102: .Nm
                    103: must be running as root.
1.34      millert   104: Note that in this mode
1.18      aaron     105: .Nm
                    106: will not be able to send a
                    107: .Dv SIGHUP
                    108: signal to
1.34      millert   109: .Xr syslogd 8 .
1.20      aaron     110: .It Fl v
1.33      millert   111: Place
                    112: .Nm newsyslog
                    113: in verbose mode.
1.20      aaron     114: In this mode it will print out each log and its
                    115: reasons for either trimming that log or skipping it.
1.26      millert   116: .It Fl a Ar directory
                    117: Specify a
                    118: .Ar directory
                    119: into which archived log files will be written.
                    120: If
                    121: .Ar directory
1.32      jmc       122: is a relative path, it is appended to the parent directory
1.26      millert   123: of each log and the archived log is stored in the result.
                    124: If an absolute path is given, all archived logs are stored in the given
                    125: .Ar directory .
                    126: If
                    127: .Ar directory
                    128: does not exist for a specified log, it is ignored for that entry and
                    129: the log is rotated as if the
                    130: .Fl a
                    131: option was not specified.
1.20      aaron     132: .It Fl f Ar config_file
                    133: Use
                    134: .Ar config_file
                    135: instead of
                    136: .Pa /etc/newsyslog.conf
                    137: for the configuration file.
1.18      aaron     138: .El
1.28      millert   139: .Pp
                    140: If one or more
                    141: .Ar log
                    142: files are specified on the command line, only the specified logs will
                    143: be rotated.
                    144: Note that each
                    145: .Ar log
                    146: specified must have an entry in
                    147: .Pa /etc/newsyslog.conf .
1.18      aaron     148: .Pp
1.32      jmc       149: A log can be archived because of two reasons:
1.18      aaron     150: The log file can have
1.1       deraadt   151: grown bigger than a preset size in kilobytes, or a preset number of
1.18      aaron     152: hours may have elapsed since the last log archive.
                    153: The granularity of
1.13      aaron     154: .Nm
1.4       downsj    155: is dependent on how often it is scheduled to run in
                    156: .Xr cron 8 .
                    157: Since the program is quite fast, it may be scheduled to run every hour
1.1       deraadt   158: without any ill effects.
1.4       downsj    159: .Pp
1.13      aaron     160: When starting up,
                    161: .Nm
1.1       deraadt   162: reads in a configuration file to determine which logs should be looked
1.18      aaron     163: at.
                    164: By default, this configuration file is
1.4       downsj    165: .Pa /etc/newsyslog.conf .
1.1       deraadt   166: Each line of the file contains information about a particular log file
                    167: that should be handled by
1.4       downsj    168: .Nm newsyslog .
1.34      millert   169: Each line has five mandatory fields and up to three optional fields, with
1.18      aaron     170: whitespace separating each field.
                    171: Blank lines or lines beginning with a hash mark
                    172: .Pq Ql #
                    173: are ignored.
                    174: The fields of the configuration file are as
1.13      aaron     175: follows:
1.4       downsj    176: .Bl -tag -width XXXXXXXXXXXXXXXX
1.33      millert   177: .It Ar logfile_name
1.4       downsj    178: The full pathname of the system log file to be archived.
1.33      millert   179: .It Ar owner:group
                    180: This optional field specifies the owner and group for the archive file.
1.18      aaron     181: The
1.34      millert   182: .Ql \&:
1.13      aaron     183: is essential, even if the
1.4       downsj    184: .Ar owner
1.1       deraadt   185: or
1.4       downsj    186: .Ar group
1.18      aaron     187: field is left blank.
                    188: The fields may be numeric, or a name which is looked up
1.4       downsj    189: in the system password and group databases.
1.33      millert   190: For backwards compatibility, a
                    191: .Ql \&.
                    192: may be used instead of a
1.34      millert   193: .Ql \&: .
1.38    ! millert   194: If either
        !           195: .Ar owner
        !           196: or
        !           197: .Ar group
        !           198: is not specified, the owner and/or group of the existing log file is used.
1.33      millert   199: .It Ar mode
                    200: File mode (in octal) to use for created log files and archives.
                    201: .It Ar count
                    202: The number of archives to be kept besides the log file itself.
                    203: .It Ar size
1.24      millert   204: When the size of the log file (in kilobytes) reaches this point, the log
                    205: file is trimmed as described above.
1.33      millert   206: If this field is replaced by an
                    207: .Ql \&* ,
1.13      aaron     208: then the size of
1.4       downsj    209: the log file is not taken into account when determining when to trim the
                    210: log file.
1.25      millert   211: By default, files smaller than 512 bytes are not rotated unless the
1.24      millert   212: .Sq B
                    213: (binary) flag is set.
                    214: This prevents
                    215: .Nm
                    216: from rotating files consisting solely of a message indicating
                    217: that the log file has been turned over.
1.33      millert   218: .It Ar when
1.1       deraadt   219: The
1.33      millert   220: .Ar when
                    221: field can consist of an interval, a specific time, or both.
                    222: If the
                    223: .Ar when
                    224: field consists of an asterisk
                    225: .Pq Ql \&* ,
                    226: log rotation will depend only on the contents of the
                    227: .Ar size
                    228: field.
                    229: Otherwise, the
                    230: .Ar when
                    231: field consists of an optional interval in hours, possibly followed
                    232: by an
1.37      jmc       233: .So Li \&@ Sc Ns -sign
1.33      millert   234: and a time in a restricted
                    235: .Tn ISO 8601
                    236: format or by a
1.37      jmc       237: .So Li \&$ Sc Ns -sign
1.33      millert   238: and a time specification for logfile rotation at a fixed time once
                    239: per day, per week or per month.
                    240: .Pp
                    241: If a time is specified, the log file will only be trimmed if
                    242: .Nm
                    243: is run within one hour of the specified time.
                    244: If an interval is specified, the log file will be trimmed if that
                    245: many hours have passed since the last rotation.
                    246: When both a time and an interval are specified, both conditions
                    247: must be satisfied for the rotation to take place.
                    248: .Pp
                    249: There is no provision for the specification of a timezone.
                    250: There is little point in specifying an explicit minutes or seconds
                    251: component in the current implementation, since the only comparison is
                    252: .Sq within the hour .
                    253: .Ss ISO 8601 restricted time format
                    254: The lead-in character for a restricted
                    255: .Tn ISO 8601
                    256: time is an
1.37      jmc       257: .So Li \&@ Sc Ns -sign .
1.33      millert   258: The particular format of the time in restricted
                    259: .Tn ISO 8601
                    260: is:
                    261: .Sm off
                    262: .Oo Oo Oo Oo Oo
                    263: .Va \&cc Oc
                    264: .Va \&yy Oc
                    265: .Va \&mm Oc
                    266: .Va \&dd Oc
                    267: .Oo Li \&T
                    268: .Oo Va \&hh
                    269: .Oo Va \&mm
                    270: .Oo Va \&ss
                    271: .Oc Oc Oc Oc Oc .
                    272: .Sm on
                    273: Optional date fields default to the appropriate component of the
                    274: current date; optional time fields default to midnight
                    275: For example, if today is January 22, 1999, the following date specifications
                    276: are all equivalent:
                    277: .Pp
                    278: .Bl -item -compact -offset indent
                    279: .It
                    280: .Ql 19990122T000000
                    281: .It
                    282: .Ql 990122T000000
                    283: .It
                    284: .Ql 0122T000000
                    285: .It
                    286: .Ql 22T000000
                    287: .It
                    288: .Ql T000000
                    289: .It
                    290: .Ql T0000
                    291: .It
                    292: .Ql T00
                    293: .It
                    294: .Ql 22T
                    295: .It
                    296: .Ql \&T
                    297: .It
                    298: .Ql \&
                    299: .El
                    300: .Ss Day, week and month time format
                    301: The lead-in character for day, week and month specification is a
1.37      jmc       302: .So Li \&$ Sc Ns -sign .
1.33      millert   303: The particular format of day, week and month specification is:
                    304: .Op Va D\&hh ,
                    305: .Op Va W\&w Ns Op Va D\&hh
                    306: and
                    307: .Op Va M\&dd Ns Op Va D\&hh ,
                    308: respectively.
                    309: Optional time fields default to midnight.
                    310: The ranges for day and hour specifications are:
                    311: .Pp
                    312: .Bl -tag -width Ds -compact -offset indent
                    313: .It Ar hh
                    314: hours, range 0 ... 23
                    315: .It Ar w
                    316: day of week, range 0 ... 6, 0 = Sunday
                    317: .It Ar dd
                    318: day of month, range 1 ... 31, or the letter
                    319: .Em L
                    320: or
                    321: .Em l
                    322: to specify the last day of the month.
                    323: .El
                    324: .Ss Some examples:
                    325: .Bl -tag -width Ds -compact -offset indent
                    326: .It Ar $D0
                    327: rotate every night at midnight
                    328: (same as
                    329: .Ar @T00 )
                    330: .It Ar $D23
                    331: rotate every day at 23:00 hr
                    332: (same as
                    333: .Ar @T23 )
                    334: .It Ar $W0D23
                    335: rotate every week on Sunday at 23:00 hr
                    336: .It Ar $W5D16
                    337: rotate every week on Friday at 16:00 hr
                    338: .It Ar $M1D0
                    339: rotate on the first day of every month at midnight
                    340: (i.e., the start of the day; same as
                    341: .Ar @01T00 )
                    342: .It Ar $M5D6
                    343: rotate on every 5th day of the month at 6:00 hr
                    344: (same as
                    345: .Ar @05T06 )
                    346: .El
                    347: .Pp
                    348: .It Ar flags
                    349: The optional
1.4       downsj    350: .Ar flags
1.1       deraadt   351: field specifies if the archives should have any special processing
1.18      aaron     352: done to the archived log files.
                    353: The
1.13      aaron     354: .Sq Z
                    355: flag will make the archive
1.4       downsj    356: files compressed to save space using
                    357: .Xr gzip 1
                    358: or
                    359: .Xr compress 1 ,
1.18      aaron     360: depending on compilation options.
                    361: The
1.13      aaron     362: .Sq B
                    363: flag means that the file is a
1.8       aaron     364: binary file, and so the ASCII message which
1.13      aaron     365: .Nm
1.1       deraadt   366: inserts to indicate the fact that the logs have been turned over
1.18      aaron     367: should not be included.
                    368: The
1.13      aaron     369: .Sq M
                    370: flag marks this entry as a monitored
1.4       downsj    371: log file.
1.22      wcobb     372: The
                    373: .Sq F
                    374: flag specifies that symbolic links should be followed.
1.33      millert   375: .It Ar monitor
1.31      millert   376: Specify the username (or email address) that should receive notification
                    377: messages if this is a monitored log file.
1.18      aaron     378: Notification messages are sent as email; the operator
1.13      aaron     379: deserves what they get if they mark the
1.5       downsj    380: .Xr sendmail 8
1.6       d         381: log file as monitored.
1.33      millert   382: This field is only valid when the
                    383: .Sq M
                    384: flag is set.
                    385: .It Ar pid_file
                    386: This optional field specifies a file containing the PID of a process to send a
                    387: signal (usually
                    388: .Dv SIGHUP )
                    389: to instead of
1.7       millert   390: .Pa /var/run/syslog.pid .
1.33      millert   391: .It Ar signal
1.18      aaron     392: Specify the signal to send to the process instead of
                    393: .Dv SIGHUP .
                    394: Signal names
1.16      millert   395: must start with
                    396: .Dq SIG
1.18      aaron     397: and be the signal name, not the number, e.g.,
1.23      millert   398: .Dv SIGUSR1 .
1.33      millert   399: .It Ar command
                    400: This optional field specifies a command to run instead of sending a signal
                    401: to the process.
1.18      aaron     402: The command must be enclosed in double quotes
1.30      deraadt   403: .Pq Ql \&" .
1.29      millert   404: The empty string,
                    405: .Ql \&"\&" ,
                    406: can use used to prevent
                    407: .Nm
                    408: from sending a signal or running a command.
1.18      aaron     409: You cannot specify both a command and a PID file.
1.25      millert   410: .Em NOTE:
1.19      millert   411: If you specify a command to be run,
                    412: .Nm
                    413: will not send a
                    414: .Dv SIGHUP to
                    415: .Xr syslogd 8 .
1.4       downsj    416: .El
                    417: .Sh FILES
                    418: .Bl -tag -width /etc/newsyslog.conf
                    419: .It Pa /etc/newsyslog.conf
1.11      aaron     420: default configuration file
1.4       downsj    421: .El
                    422: .Sh SEE ALSO
1.8       aaron     423: .Xr compress 1 ,
1.4       downsj    424: .Xr gzip 1 ,
                    425: .Xr syslog 3 ,
1.8       aaron     426: .Xr syslogd 8
1.21      mpech     427: .Sh AUTHORS
1.18      aaron     428: .Bd -unfilled
1.1       deraadt   429: Theodore Ts'o, MIT Project Athena
                    430: Copyright 1987, Massachusetts Institute of Technology
1.4       downsj    431: .Ed