Blog
The Blog

KB N°2672 FORCE LOG ROTATION

Olfeo On-Premise knowledge base
June 2, 2023

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.

Context

Logrotate is a system tool that limits the size of log files in the /var/log directory by archiving them at regular intervals. It is installed by default in most GNU/Linux distributions.

For each log file, logrotate performs 2 operations:

  1. Rotation: archives the log file under a different name and deletes the oldest archive (e.g. syslog.1).
  2. Compression: may compress the log file before archiving (.gzip compression).

The global configuration file is: /etc/logrotate.conf.

The script may sometimes run into problems, affecting the log files it is supposed to compress. This can lead to the creation of large log files, or even saturation of disk space.

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.

Validation

Large files are compressed, and the server saves disk space.