LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-20-2009, 05:45 AM   #1
dappa_don
LQ Newbie
 
Registered: Jan 2009
Posts: 12

Rep: Reputation: 0
mtime


Hi all,

I want to create a script that archive of files that are older then 7 days. I want to use the mtime command but am unsure on the syntax.

what command would i use to move a file to a sub directory if it is older then 7 days.

many thanks
 
Old 08-20-2009, 05:48 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
find .... -exec mv {} target \;
 
Old 08-20-2009, 06:10 AM   #3
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by dappa_don View Post
Hi all,

I want to create a script that archive of files that are older then 7 days. I want to use the mtime command but am unsure on the syntax.

what command would i use to move a file to a sub directory if it is older then 7 days.

many thanks


Code:
find . -type f -mtime +7 -exec command {} \;
command being command you wish to execute
 
Old 08-20-2009, 06:35 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You said you wanted to archive files older than 7 days. Did you want them removed as well?
If not, you will be re-archiving (backing up) files again and again. Normally one wants to back up new files.
 
  


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
mtime option in find command ahmedb72 Linux - Newbie 7 06-23-2009 10:48 AM
using find to compare file mtime with another file's mtime TheFueley Linux - Newbie 1 12-23-2008 09:06 PM
mtime in find vs ls lslade Linux - Software 0 11-17-2005 02:06 PM
why does sftp change mtime file attribute? hazelhill Linux - Software 3 10-17-2004 10:42 PM
ls --mtime ? mikshaw Linux - Newbie 11 01-25-2004 03:09 AM


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

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