Pages

Sunday, November 26, 2023

crontab to delete old dmp files

crontab
11 11 * * * /software/oracle/oracle/scripts/del_old_dmp_files/del_old_dmp.sh

del_old_dmp.sh
#!/bin/bash

WORK_DIR=/software/oracle/oracle/scripts/del_old_dmp_files
EXP_DIR=/backup/ora_exp
LOG_FILE=${WORK_DIR}/del_old_dmp.log
RUN_DATE=`date +"%Y%m%d"_"%H%M%S"`

cd ${WORK_DIR}
echo "=========================" >> ${LOG_FILE}
echo "Start Delete old dmp files at ${RUN_DATE}" >> ${LOG_FILE}

for f in `ls -1 ${EXP_DIR}  | grep export | grep dmp | grep igt`
do
 echo "Deleting File $f" >> ${LOG_FILE}
 echo "rm -f ${EXP_DIR}/$f" >> ${LOG_FILE}
 rm -f ${EXP_DIR}/$f
done
echo "=========================" >> ${LOG_FILE}

No comments:

Post a Comment