Linux

Steps to Manage logs in Linux using Logrotate

In this tutorial, you will learn the simple steps to manage logs in Linux using logrotate. The Logrotate is used in all Linux distribution like Ubuntu, Amazon Linux, RHEL, CentOS for managing logs which are generated by Linux machine.

Logrotate is best to manage logs by rotating logs, compress, and remove automatically. Logrotate also allows you to perform/handle logs every day, weekly, monthly or as per the size of the logs (as it grows).

Steps to install logrotate in Ubuntu:

Checkout logrotate options:

Example for Logrotate:

Logrotate path:

Example to configure logrotate for Jenkins logs

Create Jenkins file in “/etc/logrotate.d/” and below lines.

The summary of this file:

weekly – Log records rotate weekly.

copytruncate –Truncate the log.

rotate 52 –Log records are turned around 52 instances earlier than being eliminated.

compress – The old versions of log records are compressed with gzip

delaycompress – It delay compression of the previous log file to the subsequent rotation cycle.

notifempty – It do not rotate the log if it is empty.

size 10k – logrotate runs if the file size is equivalent to or more 10K.

dateext –It archive old versions of log files adding a date extension like YYYYMMDD

maxage 10 –Remove rotated logs older than 10 days.

compresscmd-It specifies which command to use to compress log files.

You can check the status of logrotate:

These are the steps to manage logs in Linux using logrotate.

Related Articles

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close

Adblock Detected

Please consider supporting us by disabling your ad blocker