I have a folder /home/usr/logs/
which contain log files which are older than 1 day. I wish to compress all the log files older than one day to separate compressed archives (e.g. zip or tar.gz) and move them to the folder /home/usr/logs/archive
.
The log files are on naming formats, such as valid.app5s.log.1019
, app5s.gf3sts.1019
, valid.app5s.gf3log.1019
, app5s.gf3log.1019
, app5s.gf1sts.1019
, valid.app5s.gf1log.1019
, app5s.sts.1019
.
I tried like this:
find . -mtime +1 -exec zip filename.zip '{}' + && mv filename.zip archive/ \;
But those files are not zipped properly. Will anyone please help me in figuring out the mistake my code?