ATTENTION: there are many articles about rotating log files by date/time. But i want to rotate log files by filesize. Is it possible?
i have apache access_log file which is growing largely and taking up the entire server free space after 2/3 weeks. As a result my server sees no more free space after 2/3 weeks and i have to manually clean up the log file every 2/3 weeks.
Here is what i want to do:
- rotate the access_log file at every 5 MegaBytes.
- don't want to have more than 20 such files.
- if we reach 20x5MB files, then should remove the oldest log file first before creating a new rotation
Is it possible to do this?
Use the "size" parameter in the logrotate.conf to fix the max file size of the log file and the "rotate" option fix the number of rotation thus you can put:
as usual, man logrotate is your best friend