Configuring logrotate

The logrotate tool allows you to rotate the logs that are generated by applications and scripts

It keeps your log directories clutter-free and minimizes disk usage when correctly configured.

How to do it…

The logrotate tool is installed by default, but I will include the installation instructions here for completeness. This recipe will show you how to rotate logs for rsyslog. We will rotate the logs everyday, add an extension based on the date, compress them with a one-day delay, and keep them for 365 days. Perform the following steps:

  1. First, to install logrotate, perform the following command:
    ~]# yum install -y logrotate
    
  2. Ensure that it's enabled through the following:
    ~]# systemctl restart crond
    
  3. Open /etc/logrotate.d/syslog ...

Get Red Hat Enterprise Linux Server Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.