'Truncate older logs after the log file size reaches a particular size

I've my application running on one of the Docker containers in AWS Fargate(serverless compute engine) where I'm using a bind volume to tee application logs as follows:

/app.bin 2>&1 | tee /logs/app.log

The AWS bind volumes can grow maximum up to 200 GB, so I want to truncate the older logs once the size of my log file i.e. app.log reaches to some specific number(let's say 190 GB).

Any ideas on how do we achieve this log-rotation? I figured out that maybe I can use logrotate command along with tee. What are the other ways? How should I do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source