OceanDataTools/openrvdas

Compress older logs after rotation

Opened this issue · 4 comments

rgov commented

I was investigating the OpenRVDAS deployment on RV Odyssey and noticed that the disk was full with over 26 GB of log files. A quick gzip brought that down to 4 GB.

It would be nice if there were an option to compress log files once they're rotated out. Or keep n days of uncompressed logs and compress the older ones.

It's still very easy to use gzipped log files since there's the gzcat utility for shell pipelines and Python has the gzip module. You can configure web servers to pass gzipped files through with Content-Encoding: gzip such that the client decompresses them transparently.

There might be a utility already installed (on Ubuntu at least) that can help with this:
https://www.digitalocean.com/community/tutorials/how-to-manage-logfiles-with-logrotate-on-ubuntu-22-04

Was doing work on Revelle and took the logrotate approach for the OpenRVDAS logfiles. Was pretty simply to setup:

  1. Created a new logrotate config from openrvdas: /etc/logrotate.d/openrvdas
  2. Add the following to the config file:
/var/log/openrvdas/*.stderr {
        monthly
        compress
        delaycompress
        missingok
        notifempty
        create 644 rvdas rvdas
}

Will check back in a few weeks to confirm it's working as intended.
This VM is running Ubuntu 22.04