第一步先做一个备份
# !/bin/sh export ORACLE_BASE=/home/oracle/ app export ORACLE_HOME = $ORACLE_BASE /oracle/product/ 11.2 . 0 / dbhome_1 export ORACLE_SID = orcl export LD_LIBRARY_PATH = $ORACLE_HOME /bin: $PATH : $HOME / bin // 注意是冒号 rq =`date ' +%Y%M%D%H%M ' ` /home/oracle/app/oracle/product/ 11.2 . 0 /dbhome_1/bin/ exp oracle/oracle @orcl12 owner=oracle file=/home/oracle/backup/oracleBack_ $rq .dmp log =/home/oracle/backup/oracleBack_ $rq . log // 压缩文件名 ordatabak =oracleBack_ $rq .tar. gz dmpbak =oracleBack_ $rq . dmp logbak =oracleBack_ $rq . log days = 7 cd /home/oracle/ backup tar -zcvf $ordatabak $dmpbak $logbak find " /home/oracle/backup " -type f -name " *.dmp " - exec rm {} \ ; find " /home/oracle/backup " -type f -name " *.log " - exec rm {} \ ; find " /home/oracle/backup " -type f -name " *.tar.gz " -mtime + $days - exec rm -rf {} \ ; //这里需要注意 {} \;之间有空格 -mtime + $days之间有空格