Skip to content

Latest commit

 

History

History

logrotate

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

logrotate

Loop logging of standard inputs to several files

This is a command-line tool for circularly writing the output of other programs to some files via a pipe ("|").

Written using ulog's asynchronous fifo and extended headers for file loop writing.

Usage example

your_program | logrotate --file-path /tmp/example/log.txt --file-size=100000 --file-number=3

This will output the output of your program to /tmp/example/log.txt through logrotate, and limit the size and number of a single file according to the options.

Eventually there will be log.3.txt, log.2.txt, log.1.txt, log.txt in the /tmp/example directory.

These files will circulate in the order log.(N).txt -> log.(N+1).txt, and always keep at least 3 complete files.

The log.txt can be viewed in real time using tail -f /tmp/example/log.txt.

Command line options

> logrotate --help
Usage: logrotate [OPTION]...
Loop logging of standard inputs to several files

  -h, --help                   Print help and exit
  -V, --version                Print version and exit
      --file-path=path         File path to record log
      --file-size=size         Size of each file
      --file-number=number     Maximum number of files
      --fifo-size=size         Fifo size  (default='32768')
      --stdout                 Should print to stdout  (default=off)
      --flush-interval=second  Interval between flush  (default='0')

Command line options are generated by the gnu gengetopt tool with getopt. cmdline.c/h files are generated by the gengetopt < logrotate_getopt.ggo command.