logrotate
is a Linux utility designed to ease the administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large Source 0.
The primary purpose of logrotate
is to manage the lifecycle of log files, ensuring they do not fill up the entire filesystem. When a log file reaches a certain size, logrotate
renames it by appending a timestamp or sequence number, creates a new file with the original name, and continues writing to the new file. It can also compress the old log file, archive it, or even delete it, depending on the configuration Source 2, Source 4.
By default, logrotate
operates as a daily cron job. This means it checks all configured log files and performs any necessary actions based on the conditions defined in its configuration files. The main configuration file is located at /etc/logrotate.conf
, and additional configuration files can be added to the /etc/logrotate.d/
directory for specific applications Source 2.
In summary, logrotate
is a valuable tool for managing log files in Linux systems, helping to ensure that logs do not consume excessive disk space and that they are easily accessible for troubleshooting purposes.