LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 02: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, 03:26 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
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, 03: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


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


All times are GMT -5. The time now is 11:46 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration