How to configure log rotation using the logrotate utility in Linux?
The logrotate utility is designed for automatic management of large log files in Linux operating systems. It allows you to regularly compress, archive, delete, and move old logs, preventing the system disk from becoming completely full with redundant text data.
The utility configuration is divided into a global parameter file and separate configuration files for each application, which are usually located in the special system directory etc logrotate d. Each such file describes a specific processing rule for a certain log or group of files.
The main parameters for configuring rotation include specifying the frequency of process execution, the minimum file size to start processing, and the total number of retained archive copies. You can also configure the automatic creation of empty files in place of moved ones and the application of gzip compression algorithms to save disk space.
To check the correctness of written rules and debug the system operation without waiting for the scheduler's scheduled run, a special test mode of the utility is used. Running with the verbose output key allows you to see exactly what actions will be applied to log files based on the current configuration.