# phpman > man > multilog(8)

[multilog(8)](https://www.chedong.com/phpMan.php/man/multilog/8/markdown)                            System Manager's Manual                           [multilog(8)](https://www.chedong.com/phpMan.php/man/multilog/8/markdown)



## NAME
       multilog  -  reads a sequence of lines from stdin and appends selected lines to any number of
       logs.

## SYNOPSIS
       **multilog** _script_

## DESCRIPTION
       _script_ consists of any number of arguments. Each argument specifies one action.  The  actions
       are  carried  out  in  order  for  each  line  of  input. Note that actions may contain shell
       metacharacters that need to be quoted when **multilog** is run from a shell.

       **multilog** exits 0 when it sees the end of stdin. If stdin has a partial final line then **multi**‐‐
       **log** inserts a final newline.

       **multilog**  writes a message to stderr and exits 111, without reading any input, if it runs out
       of memory or if another **multilog** process is writing to one of the same automatically  rotated
       logs.

       If **multilog** has trouble writing to disk after it starts reading input, it writes a message to
       stderr, pauses, and tries again, without losing any data. Note that this may block  any  pro‐
       gram feeding input to **multilog**.

       If **multilog** receives a TERM signal, it will read and process data until the next newline, and
       then exit, leaving stdin at the first byte of data it has not processed.

## SELECTING LINES
       Each line is initially selected. The action

       **-**_pattern_
              deselects the line if _pattern_ matches the line. The action

       **+**_pattern_
              selects the line if _pattern_ matches the line.

       _pattern_ is a string of stars and non-stars. It matches any concatenation of  strings  matched
       by  all  the  stars and non-stars in the same order. A non-star matches itself. A star before
       the end of _pattern_ matches any string that does not include the next character in _pattern_.  A
       star at the end of _pattern_ matches any string.

       For example, the action

         +hello

       selects hello. It does not select hello world.

       The action

         -named[*]: Cleaned cache *

       deselects  named[135]: Cleaned cache of 3121 RRs. The first star matches any string that does
       not include a right bracket.

       The action

         -*

       deselects every line.

       To save memory, **multilog** actually checks pattern against only the first  1000  characters  of
       each line.

## ALERTS
       The action

       **e**      prints (the first 200 bytes of) each selected line to stderr.

## STATUS FILES
       The action

       **=**_file_  replaces  the  contents  of  _file_  with  (the first 1000 bytes of) each selected line,
              padded with newlines to 1001 bytes. There is no protection of _file_ against power  out‐
              ages.

              For example, the sequence of actions

                   -*
                   +STAT*
                   =log/status

              maintains log/status as a copy of the most recent line starting with STAT.

## TIMESTAMPING
       The action

       **t**      inserts  an  @, a precise timestamp, and a space in front of each line, using the same
              format as [**tai64n**(8)](https://www.chedong.com/phpMan.php/man/tai64n/8/markdown).  This is required to be the first action.

       Patterns apply to the line after the timestamp is inserted. For example, if

         multilog t '-*' '+* fatal: *' ./main

       reads the line

         fatal: out of memory

       then it will log a line such as

         @400000003b4a39c23294b13c fatal: out of memory

       with the first * matching the timestamp.

       You can use [**tai64nlocal**(8)](https://www.chedong.com/phpMan.php/man/tai64nlocal/8/markdown) to convert these timestamps to human-readable form.

## AUTOMATICALLY ROTATED LOGS
       If _dir_ starts with a dot or slash then the action

       _dir_    appends each selected line to a log named _dir_.  If _dir_ does not exist,  **multilog**  cre‐
              ates it.

              Do  not  attempt  to write to one log from two simultaneous **multilog** processes, or two
              actions in one process.

              The log format is as follows.  _dir_ is a directory containing some number  of  old  log
              files, a log file named _current_, and other files for **multilog** to keep track of its ac‐
              tions. Each old log file has a name beginning with @, continuing with a precise  time‐
              stamp showing when the file was finished, and ending with one of the following codes:

       **.s**     This file is completely processed and safely written to disk.

       **.u**     This file was being created at the moment of an outage. It may have been truncated and
              has not been processed.

              Beware that NFS, async filesystems, and softupdates filesystems may discard files that
              were not safely written to disk before an outage.

              While **multilog** is running, _current_ has mode 644. If **multilog** sees the end of stdin, it
              writes _current_ safely to disk, and sets the mode of _current_ to 744. When it  restarts,
              it sets the mode of _current_ back to 644 and continues writing new lines.

              When  **multilog**  decides  that _current_ is big enough, it writes _current_ safely to disk,
              sets the mode of _current_ to 744, and renames _current_ as an old log file. The action

       **s**_size_  sets the maximum file size for subsequent _dir_ actions.  **multilog** will decide that _cur__‐
              _rent_ is big enough if _current_ has _size_ bytes.  (**multilog** will also decide that _current_
              is big enough if it sees a newline within 2000 bytes of  the  maximum  file  size;  it
              tries  to  finish  log  files  at  line  boundaries.)   _size_  must be between 4096 and
              16777215. The default maximum file size is 99999.

              In versions 0.75 and above: If **multilog** receives an ALRM signal,  it  immediately  de‐
              cides that _current_ is big enough, if _current_ is nonempty.  The action

       **n**_num_   sets  the  number  of log files for subsequent _dir_ actions. After renaming _current_, if
              **multilog** sees _num_ or more old log files, it removes the old log file with the smallest
              timestamp.  _num_ must be at least 2. The default number of log files is 10. The action

       **!**_processor_
              sets  a _processor_ for subsequent _dir_ actions.  **multilog** will feed _current_ through _pro__‐
              _cessor_ and save the output as an old log file instead of _current_.  **multilog** will  also
              save  any  output that _processor_ writes to descriptor 5, and make that output readable
              on descriptor 4 when it runs _processor_ on the next log file. For reliability,  _proces__‐
              _sor_  must  exit  nonzero if it has any trouble creating its output; **multilog** will then
              run it again. Note that running _processor_ may block any program feeding input to  **mul**‐‐
              **tilog**.

## SEE ALSO
       [supervise(8)](https://www.chedong.com/phpMan.php/man/supervise/8/markdown),   [svc(8)](https://www.chedong.com/phpMan.php/man/svc/8/markdown),   [svok(8)](https://www.chedong.com/phpMan.php/man/svok/8/markdown),  [svstat(8)](https://www.chedong.com/phpMan.php/man/svstat/8/markdown),  [svscanboot(8)](https://www.chedong.com/phpMan.php/man/svscanboot/8/markdown),  [svscan(8)](https://www.chedong.com/phpMan.php/man/svscan/8/markdown),  [readproctitle(8)](https://www.chedong.com/phpMan.php/man/readproctitle/8/markdown),
       [fghack(8)](https://www.chedong.com/phpMan.php/man/fghack/8/markdown), [pgrphack(8)](https://www.chedong.com/phpMan.php/man/pgrphack/8/markdown), [tai64n(8)](https://www.chedong.com/phpMan.php/man/tai64n/8/markdown),  [tai64nlocal(8)](https://www.chedong.com/phpMan.php/man/tai64nlocal/8/markdown),  [setuidgid(8)](https://www.chedong.com/phpMan.php/man/setuidgid/8/markdown),  [envuidgid(8)](https://www.chedong.com/phpMan.php/man/envuidgid/8/markdown),  [envdir(8)](https://www.chedong.com/phpMan.php/man/envdir/8/markdown),
       [softlimit(8)](https://www.chedong.com/phpMan.php/man/softlimit/8/markdown), [setlock(8)](https://www.chedong.com/phpMan.php/man/setlock/8/markdown)

       <http://cr.yp.to/daemontools.html>



                                                                                         [multilog(8)](https://www.chedong.com/phpMan.php/man/multilog/8/markdown)
