3

I want to use logrotate for managing my logs. I find the compressing option really useful. However gzip (the compression by default) isn't the best for my logs (Experimentally, other compression can be twice to 5 times more efficient).

Is it possible to change the type of compression ? I didn't find any information on it.

Peni
  • 626
  • 1
  • 7
  • 18
  • 1
    Looking at the [man page](http://manpages.ubuntu.com/manpages/artful/man8/logrotate.8.html), I see options like `compresscmd` and related. – Dan Mašek Feb 07 '18 at 16:02

1 Answers1

6

Default compression of log files in logrotate is gzip. In case that you want more efficient compression, you can switch gzip compression with bzip2 compression. There are two options:

1- Specify compression in your config file:

/tmp/output.log {
        size 1k
        copytruncate
        create
        compress
        compresscmd /bin/bzip2
        compressext .bz2
        rotate 4
}

2- Add bzip2 compression in your /etc/logrotate.conf file

... 
#compress
compresscmd /usr/bin/bzip2
...
bishop
  • 360
  • 5
  • 21