Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Search Forums:



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-20-2007
Registered User
 

Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old 04-20-2007
awk awk is offline
Registered User
 

Join Date: Feb 2007
Posts: 135
Thanks: 0
Thanked 0 Times in 0 Posts
find ./ -type f -mtime +7 -exec rm -f {} \;

Warning, as coded, this will remove ALL files in the current directory and all subdirectories that were not either created or modified in the last 7 days.

Other coding will be necessary to restrict to only current directory.
Sponsored Links
    #3  
Old 04-20-2007
Registered User
 

Join Date: Apr 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
I want to move all files older than 1 day to an archive directory that is a subdirectory. How do I do that without whacking my archive which is a subdirectory?
    #4  
Old 04-20-2007
Registered User
 

Join Date: Apr 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
great, assuming I know that the files are all sport.xxxx where .xxxx is the current date e.g. 0420 for April 20, and also assuming we know the directory, I could write the code as: find \usr3\export\sport.* -type f -mtime +7 -exec rm -f; does this code will find files that are older than 7 days with the name bag.*** and delete them? thanks for the help
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting files older than 7 days shezam Shell Programming and Scripting 4 07-09-2008 04:40 AM
delete files and folders older than 3 days melanie_pfefer Shell Programming and Scripting 7 12-18-2006 11:58 AM
tar files older than 30 days wfch UNIX for Dummies Questions & Answers 6 04-19-2004 04:40 AM
How can I delete files older than 7 days? odogbolu98 UNIX for Dummies Questions & Answers 3 02-26-2002 07:35 PM
delete files older than 7 days lesstjm UNIX for Dummies Questions & Answers 1 11-06-2001 09:43 AM



All times are GMT -4. The time now is 03:52 AM.