Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Our outsourced IT service provider runs the following script via cron to clean up Oracle core and trace files. It clearly is not a well-written script, but my question for the Serverfault crowd is whether there is an error or boundary condition that would have it remove other directories, such as these:

/ora/admin/SCRM01P/bdump /ora/admin/SCRM01P/cdump /ora/admin/SCRM01P/pfile /ora/admin/SCRM01P/udump

We recently had these directories deleted on a production system, crashing Oracle. Have a look at this code. Your insight is appreciated, as I am not very good at Korn shell.

#This script check the utilization of the location "/ora/admin/SCRM01P" 
#and if this exceeds the threshold which is 75%, then it attemps to remove all of the 
#core dump files which are "core_*" and "cdmp_*" 
#Otherwise, is removes these core dumps that are older than 7 days 
 cd ${TOP_DIR} 
 USED=$(df -k ${TOP_DIR} |tail -1|awk '{print $5}'|grep \%|sed 's/%//') 
 [ ${USED} -gt ${THRESHOLD} ] && MTIME=-1 
 find ${TOP_DIR}/* -mtime +${MTIME} -type d \( -name "core_*" -o -name "cdmp_*" \) 2>/dev/null|while read DIRTOREMOVE 
        rm -rf $DIRTOREMOVE 
        #Due to a known Soralis issue, the directory may not be removed by the command above 
        rmdir $DIRTOREMOVE >/dev/null 2>&1 
 find ${TOP_DIR}/* -mtime +${MTIME} -name "*.trc"  -size +2000 2>/dev/null|while read TRACE_FILE 
        cp /dev/null ${TRACE_FILE} 
share|improve this question
“Soralis” is a great typo! – automatthias Jan 14 '12 at 18:16

One condition could be if this kind of directory existed (note the space):

/ora/admin/SCRM01P/bdump secondword/core_foo

The while command separates words by white space, so the while loop body would be called two times, once with /ora/admin/SCRM01P/bdump and once with secondword/core_foo.

share|improve this answer
Thanks. I suspect this is what happened, though without knowing the original list of files that were deleted, it's tough to confirm. We disabled the script and it has been re-written, with logging and sanity checking before a file or directory is deleted. – Dave Jan 20 '12 at 21:27

You can test this yourself. change the

    rm -rf $DIRTOREMOVE 
    #Due to a known Soralis issue, the directory may not be removed by the command above 
    rmdir $DIRTOREMOVE >/dev/null 2>&1 


echo "Deleting $DIRTOREMOVE"

and then change

cp /dev/null ${TRACE_FILE}


echo "Truncating ${TRACE_FILE}"

Which should show you what is being worked on.

share|improve this answer
Thanks. Logging what has been deleted should be in all housekeeping scripts. It's now been added to the specific script in this post and a fleet-wide review is underway so assess every script against a quality standard. – Dave Jan 20 '12 at 21:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.