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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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" |
| |||
| 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 |
| ||||
| 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. |