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 03-29-2009, 01:25 PM   #1
exxoid
LQ Newbie
 
Registered: Mar 2009
Location: Vancouver
Posts: 8

Rep: Reputation: 0
Post Shell script/cmd to remove old folders in a directory?


Hello,

Hoping someone could help me here, we have a back-up that takes snapshots of one of our DB servers and copies over the files to another server's directory for back-up.

This directory can grow rapidly with many back-ups as they are taken on a 5-minute timer.

I was looking for a shell script/cmd line to remove any folders in a specific directory that is older than 10 days.

Anyone able to help?

Thank you.
 
Old 03-29-2009, 01:38 PM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Code:
find /dir/to/backups -mtime +10 -exec echo rm {} +
I put an echo command in there so you don't accidentally nuke all your backups on the first go. Make sure the output is as you expect, then remove the echo and let rm do its thing.
 
  


Reply

Tags
command, cron, deleting, directories, shell


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
remove a non empty directory in shell acidjuice Slackware 10 06-28-2011 12:02 PM
Shell Script Compare Folders corteplaneta Programming 8 09-18-2010 01:32 AM
Syncronizing folders through ftp shell script mcrosby Linux - General 12 06-01-2006 02:09 AM
remove directory with shell command? khucinx Programming 2 05-19-2004 12:59 PM
need a perl script to remove folders cccc Programming 5 03-12-2004 02:39 AM


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

Main Menu
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