• Edit
  • Delete

logrotate cheatsheet

http://www.thegeekstuff.com/2010/07/logrotate-examples/

http://linux.die.net/man/8/logrotate

Basic usage

  • Run all
    • logrotate -v /etc/logrotate.conf
  • Test one config
    • logrotate -d /etc/logrotate.d/symfony
  • Run one config
    • logrotate -v /etc/logrotate.d/symfony

 

Custom Rotator Configs

Use date in filenames, better for hardlink backups (?)

vi /etc/logrotate.d/owncloud

/var/log/owncloud.log {
        # do not ignore empty zip files
        minsize 1k
        # Use www-data user
        create 0660 www-data www-data
        # Rotate when size is reached
        size 10M
        # Compress
        compress
        # Delay compression until the second rotation cycle
        delaycompress
        # Use date extension instead of numbers, good for hardlink backups
        dateext
}

 

With wildcards

vi /etc/logrotate.d/symfony

/home/*/public_html/log/*.log {
        monthly
        rotate 12
        size: 100k
        compress
        delaycompress
        missingok
        notifempty
}