Log Rotation with Logrotate

I wrote a logrotate policy that keeps a set number of old logs, compresses them and creates a fresh log file.

Overview

I set up automatic log rotation with logrotate, including how many old logs to keep, compression and creating a new active log.

What I set out to do

  • Stop log files from growing without limit.

What I did

  • I confirmed the logrotate timer was running.
  • I wrote my own rotation policy and tested it.

Screenshots

They are in the same order as in my repository. Click one to see it full size.

How I tested it

  • The log was rotated and compressed, older logs were kept and a new active log was created.

Repository

My full notes and the original screenshots are on GitHub: linux-projects/12-log-rotation-logrotate