Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-27-2009, 06:46 AM   #1
LQ Newbie
Registered: Mar 2008
Posts: 14

Rep: Reputation: 0
Smile Removing obsolete backup files and containing directory

Hi, This is my first post in LQ

I'm an Oracle DBA. My database writes backup files to ../Backup area. After writing those file to tape i would like to remove them from disk. That would be simple for me. But I want to keep last five (5) sets of files on disk for faster restore (please All mighty never force me to need and use it).
I need a script that would do the chore for me.
Directory structure is something like this

I want to delete (rm -r) directory ../20090312 for db1 and db2 every day at 7:00

I would appreciate help from linux expert

Regards Franjo
Old 03-27-2009, 12:13 PM   #2
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
It looks like you want

rm -r /path/db{1,2}/before_today/$(date --date='3 days ago' +%Y%M%d)
Be sure to test it with
echo rm -r /path/db{1,2}/before_today/$(date --date='3 days ago' +%Y%M%d)
to make sure it's doing the right thing.

Put the above command in your crontab - see man crontab for details.
Old 03-30-2009, 07:05 AM   #3
LQ Newbie
Registered: Mar 2008
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks, I just needed what I got.
I applied solution, it works and is small and beautiful.




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
svn restore directory to a revision also removing files not part of revision Four Linux - Software 1 03-03-2009 04:18 PM
Removing Backup(~) files in fc4 coolguy_iiit Linux - Newbie 9 07-30-2006 11:45 PM
Removing files wihtout removing containing Direcotry caps_phisto Linux - General 2 10-07-2004 08:16 AM
removing obsolete files in APT m_yates Debian 1 11-15-2003 06:57 PM
Removing Obsolete Software JHuizingh Linux - General 4 02-26-2002 02:17 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration