logrotate to zip & remove but NOT rotate...

General support questions
Post Reply
Posts: 2
Joined: 2020/01/20 16:19:25

logrotate to zip & remove but NOT rotate...

Post by didds1962 » 2020/09/16 10:24:38

centos 7.

our devs have an app that wites to logs in /data/Logs

but rotates daily itself


-rw-r--r-- 1 root root 136964 Sep 13 23:59 2020-09-13.log
-rw-r--r-- 1 root root 316076 Sep 14 23:56 2020-09-14.log
-rw-r--r-- 1 root root 248682 Sep 15 23:59 2020-09-15.log
-rw-r--r-- 1 root root 123633 Sep 16 10:31 2020-09-16.log

However this app apparently (according to the dev) has no option to zip the logs > Y days old or to delete logs > X days old. But we do need to housekeep sensibly by zipping anything a day old and deleting any logfile older than 183 days.

The simplest solution is a crontab or two
find /data/Logs/ -name \*.log -type f -mtime +1 -exec gzip -9 {} \;
find /data/Logs/ -name \*.log.gz -type f -mtime +183 -exec rm -f {} \;

However ... crontabs are frownwed up[on (not my call) and we are "requested" to use logrortate where possible for such tasks. [ again, not my call ]


- i can't see how one can use logrotate to NOT rotate the logs (as they are already rotated) but to zip them > 1 day and delete them > 180

But ... maybe there is a way so for co0mpleteness I'll ask.

Im not expecting there to be a solution - after all,. its called logROTATE for a reason!

Post Reply

Return to “CentOS 7 - General Support”