Every day I'm deleting log files in a folder.find ~/folder -mtime +28 -type f -deleteNow I would like to archive and compress all files affected by above delete command and store this tar.gz in a new directory folder2.So let's assume this:~/folder:  - x1 (3 days old)  - x2 (3 days old)  - y1 (29 days old)  - y2 (29 days old)~/folder2:  - genericname1.tar.gz: (some already present archive)    - ...archive, compress and delete~/folder:  - x1  - x2~/folder2:  - genericname1.tar.gz:    - ...  - genericname2.tar.gz:    - y1    - y2
How to tar-gz all files older than 28 days in a directory?
logrotate
You can either run a script like this one (assuming GNU tar or libarchive bsdtar):find . -type f -mtime +28 -print0 | tar -czvf backup.tar.gz --null -T -Or start using logrotate (recommended). You place your custom configuration file in /etc/logrotate.d/yourfile, example file:   /var/log/news/news.crit {       monthly       rotate 2       olddir /var/log/news/old       missingok       postrotate                                 kill -HUP cat /var/run/inn.pid       endscript       nocompress   }You can see more information about all logrotate config options here