INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Remove files within a unix shell script

Remove files within a unix shell script

(OP)
Afternoon,

Iam currently running a oracle datapump through a unix shell script.
The problem i have is that the dmp files have increased over time to more or less 25 dmp files perday BUT are not deleted daily. It deletes only the first 22 files leaving the other two or three in the set directory.
HOW CAN I DELETE ALL FILES WITHIN DIRECTORY
herewith my removing of files command within my unix script

CODE

if [ -r ${EXPORTDIR}/${i}.dmp ]; then
           rm ${EXPORTDIR}/${i}.dmp
 fi 

herwith example of files not deleted from directory

CODE

rw-r-----   1 oracle   oinstall 1060347904 Nov  7 01:59 /u8/datapump/MAC/MAC20.dmp
-rw-r-----   1 oracle   oinstall 1605095424 Nov  7 01:59 /u8/datapump/MAC/MAC21.dmp
-rw-r-----   1 oracle   oinstall 898039808 Nov  7 01:59 /u8/datapump/MAC/MAC22.dmp
-rw-r-----   1 oracle   oinstall 166653952 Nov  6 01:54 /u8/datapump/MAC/MAC23.dmp
-rw-r-----   1 oracle   oinstall 36659200 Nov  6 01:54 /u8/datapump/MAC/MAC24.dmp 

Any assistance will be highly appreciated

RE: Remove files within a unix shell script

(OP)
The Value of ${i} belongs in the Oracle parfile, because i need the create statements for Db recovery so i do a export as well as a import into a SQL file
herewith what it looks like

CODE

create_exp_parfile()
{
        echo "USERID=system/${SYSTEM_001P}" > ${EXP_PARFILE}
        echo "DIRECTORY=datapump_mac" >> ${EXP_PARFILE}
        echo "VERSION=LATEST" >> ${EXP_PARFILE}
        echo "DUMPFILE=MAC%U.dmp" >> ${EXP_PARFILE}
        echo "PARALLEL=16" >> ${EXP_PARFILE}
        echo "LOGFILE=MAC.log" >> ${EXP_PARFILE}
        echo "METRICS=y" >> ${EXP_PARFILE}
        echo "CONTENT=all" >> ${EXP_PARFILE}
        echo "SCHEMAS=MAC" >> ${EXP_PARFILE}
        echo "JOB_NAME=EXP_MAC_`/usr/bin/date '+%d%m%Y'`" >> ${EXP_PARFILE}
        echo "FILESIZE=6G" >> ${EXP_PARFILE}
        echo "REUSE_DUMPFILES=y" >> ${EXP_PARFILE}
} 
the import parfile :

CODE

create_imp_parfile()
{
        echo "USERID=system/${SYSTEM_001P}" > ${IMP_PARFILE}
        echo "DIRECTORY=datapump_mac" >> ${IMP_PARFILE}
        echo "DUMPFILE=${i}%U.dmp" >> ${IMP_PARFILE}
        echo "LOGFILE=IMP.log" >> ${IMP_PARFILE}
        echo "SQLFILE=MAC.sql" >> ${IMP_PARFILE}
        echo "FULL=y"  >> ${IMP_PARFILE}
        echo "JOB_NAME=IMP_MAC_`/usr/bin/date '+%d%m%Y'`" >> ${IMP_PARFILE}
} 
WILL the rm -f ${EXPORTDIR}/*.dmp
still work in this case?

RE: Remove files within a unix shell script

(OP)
I changed the script to include the following:

CODE

do_export()
{
        if [ -r ${EXPORTDIR}/${i}.dmp ]; then
           rm -f ${EXPORTDIR}/*.dmp
        fi 
BUT TO NO AVAIL YOUR ASSISTANCE WILL BE HIGHLY APPRECIATEd

The out put directory still has the old files

CODE

-rw-r-----   1 oracle   oinstall 6442450944 Jan 11 00:09 /u8/datapump/MAC/MAC17.dmp
-rw-r-----   1 oracle   oinstall 2024898560 Jan 11 00:17 /u8/datapump/MAC/MAC18.dmp
-rw-r-----   1 oracle   oinstall 582565888 Jan 11 00:17 /u8/datapump/MAC/MAC19.dmp
-rw-r-----   1 oracle   oinstall 1042161664 Jan 11 00:17 /u8/datapump/MAC/MAC20.dmp
-rw-r-----   1 oracle   oinstall 88600576 Jan 11 00:17 /u8/datapump/MAC/MAC21.dmp
-rw-r-----   1 oracle   oinstall 2822144 Jan 10 00:09 /u8/datapump/MAC/MAC22.dmp
-rw-r-----   1 oracle   oinstall 42049536 Jan  7 00:09 /u8/datapump/MAC/MAC23.dmp
-rw-r-----   1 oracle   oinstall 56913920 Dec 24 23:58 /u8/datapump/MAC/MAC24.dmp 

RE: Remove files within a unix shell script

(OP)
Should i leave out ?

CODE

if [ -r ${EXPORTDIR}/${i}.dmp ]; then 

Because that is exactly the rm command i currently have in my script

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close