Unix Technical Forum

Sorting

This is a discussion on Sorting within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi Probably an easy one. I'm backing up some dabatase files on my AIX to a new directory each ...


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 10:30 AM
chorozon@gmail.com
 
Posts: n/a
Default Sorting

Hi

Probably an easy one. I'm backing up some dabatase files on my AIX to a
new directory each night but i only want to keep seven days worth of
backups at a time. What's the best way in a script to find which
directory is the oldest of the seven so I can then delete it?

Thanks
Simmo

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 10:30 AM
base60
 
Posts: n/a
Default Re: Sorting

chorozon@gmail.com wrote:
> Hi
>
> Probably an easy one. I'm backing up some dabatase files on my AIX to a
> new directory each night but i only want to keep seven days worth of
> backups at a time. What's the best way in a script to find which
> directory is the oldest of the seven so I can then delete it?


Read the man page for "ls"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 10:30 AM
Frank Fegert
 
Posts: n/a
Default Re: Sorting

chorozon@gmail.com wrote:
> Probably an easy one. I'm backing up some dabatase files on my AIX to a
> new directory each night but i only want to keep seven days worth of
> backups at a time. What's the best way in a script to find which
> directory is the oldest of the seven so I can then delete it?


Use 'find' with '-(a|c|m)time' and '-exec rm -r {} \;' flags.
Read here for more information:
http://publib.boulder.ibm.com/infoce...cmds2/find.htm

Regards,

Frank
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 10:31 AM
j-bo
 
Posts: n/a
Default Re: Sorting

chorozon@gmail.com wrote:
> Hi
>
> Probably an easy one. I'm backing up some dabatase files on my AIX to a
> new directory each night but i only want to keep seven days worth of
> backups at a time. What's the best way in a script to find which
> directory is the oldest of the seven so I can then delete it?
>
> Thanks
> Simmo


Although find will work, it will also traverse recursively. I am
assuming you have a directory tree similar to the following:

/db_backup/backupDir1
/db_backup/backupDir2
/db_backup/backupDir3
/db_backup/backupDir4
/db_backup/backupDir5
/db_backup/backupDir6
/db_backup/backupDir7

If so, you can determine the oldest as follows:

ls -t /db_backup | tail -n1

J.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:17 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com