How can I rotate all the log files older 30 days in a unique file.tar.gz and remove the files inserted in the archive?Before:a.log // older than 30daysb.log // older than 30daysc.log // older than 20 daysAfter:backup.tgzc.log
How to rotate old log files in a unique file.tar.gz?
rhel;logrotate
You can do the following:find . -name '*log' -mtime +30 -print0 | tar -czvf backup.tgz --remove-files --null -T -With:find options:-name '*log' -mtime +30: selects log files older than 30 days-print0: print  the  full  file  name on the standard output,  followed by a null charactertar options:--remove-files: remove files after adding them to the archive--null: reads null-terminated names (sent by find -print0)-T -: reads filenames from stdin (find's output) 