tar files older than 30 days


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers tar files older than 30 days
# 1  
Old 04-14-2004
tar files older than 30 days

Hi there,

I am trying to tar a number of files held in a specific folder. I am only interested in archiving files older than 30 days. Having read through the man entries and all available documentation I thought I'd cracked the coomand with

tar -c -z -v -N 15/04/2004 -f /wfch.tar *

This tar's up the whole of the pwd

Anyone know the correct syntax please ?
# 2  
Old 04-14-2004
Best way I know is to use a reference file...

Touch a file and use that as the reference date...

# touch -t 03091301 testfile
root:/root/LVMcommands
# ll toddfile
-rw------- 1 root sys 0 Mar 9 13:01 testfile

tar -cvf test.tar `find . -type f -newer testfile`



Here is a link to my question waay back when... with answers... http://forums1.itrc.hp.com/service/f...hreadId=203693
# 3  
Old 04-15-2004
Thanks for this. It really is appreciated

I've been working on it all day. I've checked out the link you provided as well. Every time I try running the command I end up with the folowing:

/export/home/dbadmin/dsoreceipts > ls -l t*
-rw-r--r-- 1 dbadmin academy 0 Jan 1 00:01 testfile
/export/home/dbadmin/dsoreceipts > tar -cvf test.tar 'find . -type f -newer testfile'
tar: find . -type f -newer testfile: No such file or directory

Am I missing something obvious here?
# 4  
Old 04-15-2004
Should be back tics... not single quotes

` ` not ' '
# 5  
Old 04-15-2004
Thanks again. I thought it was something obvious I'd missed.

I have ran this but it has tarred up all files younger than the reference file. I have tried changing the -newer switch to -after-date but this is classed as a bad option.

I've experimented with the following command and, although not as flexible as your suggestion it's a work around for the time been:

find . -mtime +30 | xargs tar -cvf mar_03.tar

This'll be the last time I ask Todd, but do you have an answer to your orignal reference-file command ?Smilie
# 6  
Old 04-15-2004
hehe I misread your post... -newer is for more recent files... you wanted OLDER files...

You must use the +N value to do that I think... I thought you had asked about newer...


My bad. Smilie



one more note... You can use the -I option to list the full path to the filenames in a file to be backed up... If you can generate a list of the filesyou want to backup, use this option.

find . -mtime +30 > file.out ... then you can run the tar versus a known list of files that you can edit and remove or add filenames.

Last edited by Kelam_Magnus; 04-15-2004 at 12:14 PM..
# 7  
Old 04-19-2004
MySQL

Thanks for the additional notes. I've got a file (archive_printlib) which contains a script that now works (example below):

touch -t 19040004 archive_printlib
find . -mtime +19 | xargs rm tick*
find . -mtime +19 | xargs rm hold*
find . -mtime +19 | xargs rm pass*
find . -mtime +19 | xargs rm mdlo*
find . -mtime +19 | xargs rm STAGE*
find . -mtime +19 | xargs rm WFPS*
find . -mtime +19 | xargs rm BMODCL*
find . -mtime +19 > arch.out | xargs tar -cvf mar_04_tar -I /apps/academy/live/hs/printlib/arch.out
compress mar_04.tar
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

2. UNIX for Dummies Questions & Answers

Files older than 50 days

Hi All, OS :- HP-UX wm5qa B.11.23 U ia64 1119805695 unlimited-user license I need to search files older than 50 days. I've used following command in order to search desired files, I also discoverd, it's showing today's files as well. Do you have any clue with this ? wmqa1> find .... (4 Replies)
Discussion started by: alok.behria
4 Replies

3. Shell Programming and Scripting

Need script to tar files older than 30 days

Hi all. Here's my situation: I have performance reports that run every 30 minutes saved in the format: stats_report_11251000.txt stats_report_11251030.txt stats_report_11251100.txt stats_report_11251130.txt (Obviously run at Nov 25 10 AM, 10:30 AM, 11 AM and so on...) I would... (2 Replies)
Discussion started by: jamie_collins
2 Replies

4. UNIX Desktop Questions & Answers

Find files older than 10 days

What command arguments I can use in unix to list files older than 10 days in my current directory, but I don't want to list the hidden files. find . -type f -mtime +15 -print will work but, it is listing all the hidden files., which I don't want. (4 Replies)
Discussion started by: Pouchie1
4 Replies

5. Shell Programming and Scripting

How to find files older than 30 days

Dear Friends, I have two queries. 1) I want to see the list of folders which were created 29 days ago. 2) I want to see the folders in which last created file is older than 29 days. Can it be done? Thank you in advance Anushree (4 Replies)
Discussion started by: anushree.a
4 Replies

6. Shell Programming and Scripting

How to tar, compress and remove files older than two days

Hi, I'm Eddy from Belgium and I've the following problem. I try to write a ksh script in AIX to tar, compress and remove the original *.wav files from the directory belgacom_sf_messages older than two days with the following commands. The problem is that I do not find a good combination... (4 Replies)
Discussion started by: edr
4 Replies

7. Shell Programming and Scripting

delete files more than 15 days older

i have to delete files which are older than 15 days or more except the ones in the directory Current and also *.sh files i have found the command for files 15 days or more older find . -type f -mtime +15 -exec ls -ltr {} \; but how to implement the logic to avoid directory Current and also... (3 Replies)
Discussion started by: ali560045
3 Replies

8. Solaris

Find files older than x days and create a consolidated single tar file.

Hello, I need help in finding files older than x days and creating a single consolidated tar file combining them. Can anyone please provide me a script? Thanks, Dawn (3 Replies)
Discussion started by: Dawn Bosch
3 Replies

9. Shell Programming and Scripting

Deleting files older than 7 days

Hi Guys, I want to delete folder/files older than 7 days. Im using the command below. find /test/test1 -mtime +7 -print0 | xargs -0 rm -Rf /test/test1/* which works ok, but it deletes the test1 folder as well which i dont want. The test1 folder will have a list of sub-folders which in... (4 Replies)
Discussion started by: shezam
4 Replies

10. UNIX for Dummies Questions & Answers

Removing files older than 7 days

Script help, I need to delete files that are older than 7 days. I do that automatically but I know that a cron job can do the job for me. Any help is greatly appreciated, as you can see, I am a DOS or WINDOWS guy. Little on UNIX. Thanks (3 Replies)
Discussion started by: texasoeb
3 Replies
Login or Register to Ask a Question