Log rotating with a Bash script

前端 未结 5 1653
时光取名叫无心
时光取名叫无心 2021-02-01 20:09

I have the following issue:

I have an application, which continuously produces output to stderr and stdout. The output of this application is captured in a logfile (the

5条回答
  •  南旧
    南旧 (楼主)
    2021-02-01 20:34

    You can leverage rotatelogs (docs here). This utility will decouple your script's stdout from the log file, managing the rotation in a transparent way. For example:

    your_script.sh | rotatelogs /var/log/your.log 100M
    

    will automatically rotate the output file when it reaches 100M (can be configured to rotate based on a time interval).

提交回复
热议问题