Archive files older than 30days


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Archive files older than 30days
# 1  
Old 07-24-2006
Archive files older than 30days

I have files with the names BARE01_DLY_MKT_20060724 in the source directory /biddf/ab6498/dev/ctl. I need to archive folders older than 30days. Like if i have a file named BARE01_DLY_MKT_20060622 I need to move this to /biddf/ab6498/dev/ctl/archive. How can I do this. One more thing is that I want to pass the file name namely BARE01_DLY as parameter to the script and it should see whether in the source directory there is a file oder than 30 days with that name and accrodingly move it to archive if it's older than 30days. Kindly help.
# 2  
Old 07-24-2006
I have a similar question, because I donīt know any cammand that give me the creation date because all the commands I know give me the modify date.

If anyone know the solution I am very pleasent
# 3  
Old 07-24-2006
All,

I will re-phrase my logic so that atleast somebody can give some logic.

I have files named BARE01_DLY_MKT_YYYYMMDD like wise for past 100 days in a direcotry /dev/bid/ctl.

I need to archive the files older than 30days in
/dev/bid/ctl/archive

Please suggest a method for this.
# 4  
Old 07-25-2006
You can do something like this with find (non recursive form) :

Code:
cd /dev/bid/ctl
find . \( -type d ! -name . -prune  \) -o -name 'BARE01_DLY_MKT_*' -mtime +30 -exec mv {} archive/

Jean-Pierre.
# 5  
Old 07-25-2006
Hi Jean,

I am getting this error. What does this mean?

find: -exec not terminated with ';'

Smilie
# 6  
Old 07-25-2006
The find command is incomplete :
Code:
cd /dev/bid/ctl
find . \( -type d ! -name . -prune  \) -o -name 'BARE01_DLY_MKT_*' -mtime +30 -exec mv {} archive/ \;

Jean-Pierre.
# 7  
Old 07-25-2006
The problem is that find -mtime give us the modify not create time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need command/script to archive files older than

I need to find a way to archive all files older than a given date but there are some conditions that are making it difficult for me to find the correct command: Linux based system (RH5) there are multiple layers of directory depth I need to search each file should be tar'd in it's original... (1 Reply)
Discussion started by: KaosJedi
1 Replies

2. Shell Programming and Scripting

Check files and archive the files using sftp

Hi, I have to check the files in another server using sftp to do that, below is the code i am going with #!/bin/bash export SRC_FOLDER=$1 export ARC_FOLDER=$2 HOST=as07u3456 USER=relfag sftp ${USER}@${HOST} <<EOF cd $SRC_FOLDER/DSCOR ls bye EOF echo "done" whatever the files i... (8 Replies)
Discussion started by: ursrami
8 Replies

3. 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

4. Shell Programming and Scripting

List files with *.i extension in a directory and all its subdirectories + 30days old then remove

I need to write a script to : list files with *.i extension in a directory and all its subdirectories + 30days old, save it in a file and then remove (2 Replies)
Discussion started by: lena keung
2 Replies

5. UNIX for Dummies Questions & Answers

How to archive old files from the recently added 10 files?

Hi there, I am very new to unix and having trouble with a fairly simple statement: cd /user ls -t -c1 | sed -ne '11,$p' | mv xargs archive/ What I want the code to do is sort all files in a directory by timestamp, select all of the files after the 10th file, and then move those files... (3 Replies)
Discussion started by: DSIReady
3 Replies

6. Shell Programming and Scripting

How archive the older than 30 day files to another unix server

I need to archive the older than 30 day file to another uinx server.I have wrote the below uinx script. for LOOK_DIR in /TempFiles do for FILE in `find ${LOOK_DIR} -mtime -30 -exec ls {} \;` do echo ${FILE} >> file_list ## This file will have the list of files copied and... (12 Replies)
Discussion started by: murari83.ds
12 Replies

7. Shell Programming and Scripting

how to delete the older files other than the recently added 5 files

Number of files will get created in a folder automatically daily.. so i hav to delete the older files other than the recently added 5 files.. Could u help me through this..?? (5 Replies)
Discussion started by: shaal89
5 Replies

8. UNIX for Advanced & Expert Users

how to archive logs older than 5 days & then delete them?

My code is tar -cvf logs.tar `find /usr/openv/logs/512*.log -mtime +2` && find *.log* -mtime +2 -exec rm {} \; this gives me output as: tar: Missing filenames:confused: (1 Reply)
Discussion started by: timus1980
1 Replies

9. Shell Programming and Scripting

Archive files

Hi All, I wrote this script: #!/bin/ksh while read DAYS ARCH_PATH do cd $ARCH_PATH find . \( -type d ! -name . -prune \) -o -type f -mtime +$DAYS -exec tar -cv f kay_`date +%d%m%y%H%M`.tar {} \; cd - done < filestoarchive.txt The problem is, in a folder of 7files, I would... (13 Replies)
Discussion started by: kayarsenal
13 Replies

10. UNIX for Dummies Questions & Answers

rm files older than ...

Hello, How can I remove files older than yesterday or the day before or a given day ... Thank you in advance (2 Replies)
Discussion started by: annemar
2 Replies
Login or Register to Ask a Question