
KB No. 2672 FORCE LOG ROTATION
How to force rotation and compression of system log files on the host machine or chroot.
Objective
Force log rotation and compression to manage log retention.
Background
Logrotateis a system tool that limits the size of log files in the/var/logdirectory by archiving them at regular intervals. It is installed by default in most GNU/Linux distributions.
For each log file,logrotateperforms two operations:
- Rotation: it archives the log file under a different name and deletes the oldest archive (e.g., syslog.1).
- Compression: it may compress the log file before archiving it (compression in .gzip format).
The global configuration file is as follows:/etc/logrotate.conf.
The script may sometimes encounter problems when it is launched, which affects the log files it is supposed to compress. As a result, this can lead to the creation of large log files, or even disk space saturation.
Steps
Manually restart the compression script:
/usr/sbin/logrotate -f /etc/logrotate.conf -v
In the case of a software installation (on a VM or physical machine), the operation must be performed in the chroot environment.
Validation
Large files are compressed, saving disk space on the server.