LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-10-2018, 03:06 AM   #1
azheruddin
Member
 
Registered: Dec 2011
Posts: 91
Blog Entries: 1

Rep: Reputation: Disabled
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 \;
 
Old 10-10-2018, 03:43 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,930

Rep: Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192Reputation: 1192
Write a script to do the whole tar / zip / move and use that instead of the
Code:
mv {} /XYZ
 
Old 10-10-2018, 04:24 AM   #3
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 852

Rep: Reputation: 286Reputation: 286Reputation: 286
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
 
1 members found this post helpful.
Old 10-10-2018, 04:26 AM   #4
azheruddin
Member
 
Registered: Dec 2011
Posts: 91

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Thnaks, how exactly the full command would be with tar,zip and move? that was my question
 
Old 10-10-2018, 04:53 AM   #5
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 852

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by azheruddin View Post
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?
 
1 members found this post helpful.
Old 10-10-2018, 10:20 AM   #6
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Is this homework?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron Job help to move directories older than 90 days ndenial Linux - Newbie 15 12-11-2015 04:57 PM
tar files that are more than x days old & dir with spaces j-me Linux - General 5 08-23-2013 03:06 PM
How to compress and move log older than 30 days from one folder to another LittleMaster Linux - Newbie 6 09-20-2012 12:30 AM
Need to move folders older than 5 days to a bad up directory calicowboy54 Linux - Newbie 4 01-15-2012 09:27 PM
How to move files older than 30 days gfem AIX 8 11-08-2006 04:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration