LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar & Zip then move the files older than 45 days (https://www.linuxquestions.org/questions/linux-newbie-8/tar-and-zip-then-move-the-files-older-than-45-days-4175640074/)

azheruddin 10-10-2018 03:06 AM

tar & Zip then move the files older than 45 days
 
Helllo,
I have a command in crontab which moves the files older than 45 days to the archive location.

what i need to do is to first tar and zip the files older than 45 days and move to the archive location. how below command will change as per my requirement.

Code:

find /ABC  -mtime +45 -exec mv {} /XYZ \;

TenTenths 10-10-2018 03:43 AM

Write a script to do the whole tar / zip / move and use that instead of the
Code:

mv {} /XYZ

l0f4r0 10-10-2018 04:24 AM

Something like the following should do the job:

With tar:
Code:

find /ABC -mtime +45 -exec tar -cf archive_name.tar {} + && mv archive_name.tar archive_location
With zip:
Code:

find /ABC -mtime +45 -exec zip archive_name.zip {} + && mv archive_name.zip archive_location

azheruddin 10-10-2018 04:26 AM

Thnaks, how exactly the full command would be with tar,zip and move? that was my question

l0f4r0 10-10-2018 04:53 AM

Quote:

Originally Posted by azheruddin (Post 5913099)
Thnaks, how exactly the full command would be with tar,zip and move? that was my question

Sorry but I'm not sure to understand what you're asking right now. Isn't my previous answer what you expected?
Why does your requirement include tar&zip? These are 2 similar archive algorithms (with technical differences though) so I think you need to make a choice. Or maybe you need to make 1tar + 1zip?

AwesomeMachine 10-10-2018 10:20 AM

Is this homework?


All times are GMT -5. The time now is 03:06 PM.