Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting files and folders older than 15days 2

Status
Not open for further replies.

inunix

Technical User
Jul 30, 2002
53
0
0
US
Hi

Can someone provide a script to delete files and directories older than "n" days.

Many thanks.

 
man find

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Try this.. got this from an earlier post :)

#### MOVING OLD files BEFORE A CERTAIN DATE_TIME ########

touch 200503261800 /home/etbc01/temp/tempdate.txt // creates a reference date_Time file. In this case it is 26th of MArch, 2005 at 1800 hrs.

mv `find . ! -newer /home/temp/tempdate.txt -type f` /home/temp/

ofcourse u can delete them if u want to..
Hope this helps..
 
You can also use -mtime +n if you're not too worried about exact times of creation.
 
As this is turning up every month or so I've written faq80-5793

Columb Healy
 
Thanks columb.. this is exactly what I want. Many thanks. It saved me lot of my time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top