Operating System - HP-UX
1752625 Members
4770 Online
108788 Solutions
New Discussion юеВ

How to remove files except the two recent one from a series of files in hp unix 11.23

 
SOLVED
Go to solution
akarayil
Frequent Advisor

How to remove files except the two recent one from a series of files in hp unix 11.23

We are taking export of badabase in every two hours. Now I am manually removing the old files except the two recent files.
We want to automate this process.
Can anybody help me out.
5 REPLIES 5
Yogeeraj_1
Honored Contributor

Re: How to remove files except the two recent one from a series of files in hp unix 11.23

hi,

Please clarify.

Where are you doing the export of the database?
Disk or tape?

Which database software are you using? (oracle?)

revert

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Yogeeraj_1
Honored Contributor
Solution

Re: How to remove files except the two recent one from a series of files in hp unix 11.23

hi again,

In case, you are doing disk-based export of the database, you will have to create a script that purges the old data. Then, you will also have to create a crontab entry so that the script is executed at the predetermined interval.

E.g.
Script (extract)
===============
DIR=/data/export
find $DIR -xdev -type f -mtime +2 -name '*.dmp' -exec rm -f {}+


Crontab Entry
==============

#*******************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|--------------------------
30 01 * * * /home/yogeeraj/scripts/purge_exp.sh 1> /home/yogeeraj/scripts/logfiles/output-purge_exp.crn 2>/home/yogeeraj/scripts/logfiles/error-purge_exp.crn

#*********************************************************
# min|hour |day |month|day |script
# | |of mo| |of wk|
#----|-----|-----|-----|-----|----------------------------
#*********************************************************

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Yogeeraj_1
Honored Contributor

Re: How to remove files except the two recent one from a series of files in hp unix 11.23

see also:
http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1217253


note that you should ensure that you should ensure that your recovery window is acceptable or old backup are sent to secondary media as desired.

Also, if you are using Oracle, EXP is no longer considered as an efficient backup tool. You should configure RMAN which automatically performs loads of tasks without any manual intervention. The latter also ensures proper recover of the database in cases of failures.

hope this helps too!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
akarayil
Frequent Advisor

Re: How to remove files except the two recent one from a series of files in hp unix 11.23

Thank you very much, Mr. Yogeeraj.
this solution is working fine.
I'm closing this thread
akarayil
Frequent Advisor

Re: How to remove files except the two recent one from a series of files in hp unix 11.23

suggested solution is working fine