How To Rotate Log Files In Linux?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/rotate-log-files-linux/
PINTEREST
PINTEREST
INSTAGRAM

Logs are created by different services like http, ftp, ssh etc. What do we with these logs? May be nothing but when the times came it will be important to get detailed information about error, security event etc from log files. Logs are created all times and always grows up. How can we handle to prevent these logs files to fill our disks. Here came the rotate operation or daemon. We can rotate and compress our logs file easily with simple configuration. Also information about rotated logs can be emailed to specified recipient.

Default Configuration File

Logrotate default configuratioh file resides /etc/logrotate.conf . Below is default  configuration details

There are explanations about configuration directives.

LEARN MORE  Bash Shell Export

Enable Compression For Rotated Files

Rotating log files create new log file and old files can be compressed to gain disk space like below.

Uncomment compress line or add new line

Change BackLog

How much time we will store old logs? We can set it with count like below.

This will rotate or save logfiles for 4 week if rotation is done weekly. If rotation is done daily it will hold old logs for 4 days.

Specify New Rotate Configuration

We can create new and different  rotate configuration for different logs. New rotate configuration is hold in /etc/logrotate.d/

As we see there are a lot of logrotate configuration for different logs like samba, httpd etc.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/rotate-log-files-linux/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)