Introduction

The log files size must be controlled because their size always grows over time. Each system has limited resources, and too large logs lead to performance and memory problems. Linux solves this problem with a concept called logrotate. **The logrotate is the system daemon that rotates, compresses, and mails system logs.

This tutorial shows you how to:

Prerequisites

You will need:

Step 1 — Viewing Logrotate configuration

System logs in Ubuntu 20.04 with a default configuration maintains the daemon logrotate. This daemon uses configuration files that specify all rotation details for each application. The configuration consist of the following parts:

We will view both configuration possibilities.

General logrotate configuration

As first, let's view more general configuration file /etc/logrotate.conf.

Print the content of file /etc/logrotate.conf with utility cat:

$ cat /etc/rsyslog.conf