Quantcast
Viewing all articles
Browse latest Browse all 4

Sample logrotate configurations

Logrotate is a great utility to manage and administer log files in a system. It provides you with a lot of options, namely, automatic rotation, compression and mailing of log files. Each log file can be rotated hourly, daily, weekly or monthly.

The directory thats usually used by logrotate is /etc/logrotate.d

Options

  • rotate <num> – Log files are rotated “num” times before getting deleted or mailed.
  • daily – When used this means log files should be rotated daily
  • weekly – Log files should be rotated weekly
  • monthly – Log files should be rotated monthly
  • notifempty – Don’t rotate the log if its empty
  • compress – Compress the files after rotating them
  • delaycompress – This options means to delay the compression of a log file to the next rotation cycle. This is used in combination with compress.
  • missingok – If the log file is missing, go on to the next one without issuing an error message.
  • create <mode> <owner> <group> – After rotation create a new empty file with the following properties. e.g create 640 root adm. Just “create” will ensure to inherit the properties of previous log files.

Samples

/usr/local/apache/logs/access_log {
weekly
rotate 4
copytruncate
compress
notifempty
missingok
}
/usr/local/apache/logs/error_log {
weekly
rotate 4
copytruncate
compress
notifempty
missingok
}

to Check logrotate

/usr/sbin/logrotate -d /etc/logrotate.conf

Viewing all articles
Browse latest Browse all 4

Trending Articles