24 January 2009

Make some of your log files rotate and compress

logrotate is a very useful and powerful tool.

To make some of your log files to be rotated and compressed, create a new configuration file into the logrotate "include" directory (usually /etc/logrotate.d), and add the rotate/compress rule:

/var/log/XXX.log {
rotate 3
weekly
compress
size 1M
create 0640 myUser myGroup
}


In this example, the log will go through three weekly rotations before being removed. There can be rotations if the size exceeds 1MB.
Rotated files will be compressed.
New empty file (after rotation) will be created with "0640" mode, and myUser:myGroup ownership.

No comments:

Post a Comment

Thank you for your visit, let's share your point of view: