LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 09-09-2004, 01:58 PM   #1
rbeckett
LQ Newbie
 
Registered: Sep 2004
Posts: 4

Rep: Reputation: 0
Simple script to clean up old file


I am looking for a way to clean up certain files and directories that are older than a certain number of days. Is there a script available somewhere that can help me with this. I need it to recursively check a disk for files that are older than, say 60 days and then either delete them or move there someplace else. Being new to teh scripting thing I have no idea how to accomplish this. Can anyone help?
 
Old 09-09-2004, 02:26 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
remove all ".log" (case insensitive) files recursively inside "/the/dir/to/start/at/" older that 60 days
Code:
find /the/dir/to/start/at/ -iname '*.log' -ctime +60 -exec rm {} \;
 
1 members found this post helpful.
Old 09-09-2004, 02:38 PM   #3
rbeckett
LQ Newbie
 
Registered: Sep 2004
Posts: 4

Original Poster
Rep: Reputation: 0
Thanks Chris

So to move a file instead of deleting it I would just change rm to mv and then my location?
 
  


Reply



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
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Using Audacity to clean up a wav file steve7575 Linux - Software 1 12-01-2005 11:40 AM
Help with clean-up script fiservguy Programming 5 01-27-2005 12:59 AM
Script to read a simple text file ravykanth Linux - Newbie 9 10-22-2003 04:15 AM
Simple C Shell script is not so simple elconde Programming 2 09-16-2001 11:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 11:11 AM.

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
Open Source Consulting | Domain Registration