How to setup Logrotation in Linux

Create a File here /etc/logrotate.d/
For e.g # vim /etc/logrotate.d/mytestlog

Now paste below code in it.

/var/log/YOURLOGFILEPATH.log {
weekly
rotate 5
compress
delaycompress
missingok
notifempty
create 0666 root root
}

Run a dry run (Debug) to ensure its configured fine or not.

logrotate -d /etc/logrotate.d/mytestlog

If you see any error, Fix them or post them here, i will help you OR mail me at [email protected]

Leave a Reply