$linuxjunkies
>

log rotation

also: log archival, log cycling

Log rotation is the automatic or manual process of archiving old log files and starting fresh ones to prevent logs from consuming excessive disk space. Rotated logs are typically compressed and kept for a set period before deletion.

Log rotation manages the lifecycle of log files by periodically renaming the current log, compressing it, and starting a new one. This prevents any single log file from growing too large and filling up the filesystem. The logrotate utility on Linux automates this task based on file size, age, or time interval.

The rotation process typically follows this pattern: application.log becomes application.log.1, yesterday's application.log.1 becomes application.log.2, and so on. Old numbered logs are often gzip-compressed (becoming application.log.2.gz) to save space, and the oldest ones are eventually deleted according to retention policies.

Example: A web server logging 100 MB per day might be configured to rotate daily, keeping 14 rotated copies. Without rotation, the single log file would grow to 1.4 GB in two weeks; with rotation, compressed logs occupy only a few hundred MB total while recent logs remain easily readable.

Related terms