How to set a maximum file size for log files using Logrotate
Set a maximum file size value for log files using Logrotate.
Using Logrotate, you can set a maximum file size for the log files before they are rotate (i.e. a new log file is created). In our example below, we're using Nginx log files:
Edit the logrotate configuration file:
$ nano /etc/logrotate.d/nginx
Use the
size
parameter and enter the value in MB. For example,100M
is the maximum file size for the logs before they rotate./var/log/nginx/*.log { ... size 100M ... }
Save the
/etc/logrotate.d/nginx
file changes.