PASE - how to compress old logs

By kimot, 27 December, 2022

If you need to compress old logs on IFS into archive and delete log files, you can easily use something like this command :

find -mtime +30 -type f -a \( -name "access*" -o -name "error*" \) -printf 'zip ./archive/archive-%TY%Tm.zip %f; rm %f\n' |sh

It will find all files older than 30 days which name start with "access" or "error" and will add this file into ./archive/archive-YYYYMM.zip archive.
After file is added into archive, original file is deleted from IFS.

You must have the packages "findutils" and "zip" installed to run this command.