Use tee (or equivalent) but limit max file size or rotate to new file

前端 未结 7 1603
抹茶落季
抹茶落季 2020-12-05 02:24

I would like to capture output from a UNIX process but limit max file size and/or rotate to a new file.

I have seen logrotate, but it does not work real-time. As I

7条回答
  •  悲&欢浪女
    2020-12-05 03:19

    In package apache2-utils is present utility called rotatelogs, it fully meet to your requirements.

    Synopsis:

    rotatelogs [ -l ] [ -L linkname ] [ -p program ] [ -f ] [ -t ] [ -v ] [ -e ] [ -c ] [ -n number-of-files ] logfile rotationtime|filesize(B|K|M|G) [ offset ]

    Example:

    your_program | rotatelogs -n 5 /var/log/logfile 1M
    

    Full manual you may read on this link.

提交回复
热议问题