请不要把备份脚本也放到backup_dir下,加到crontab里定时运行
#!/bin/sh
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export ORACLE_SID=orcl
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin:/u01/app/oracle/product/10.2.0/db_1/bin
export BACKUP_DIR=/orabackup
export NOW=$(date '+%Y%d%m')
exp system/system@ORACLE_SID file=$BACKUP_DIR/system$NOW.dmp log=$BACKUP_DIR/system$NOW.log full=y
cd $BACKUP_DIR
tar zcvf system$NOW.tar.gz system$NOW.dmp system$NOW.log --remove-files
find /orabackup/ -mtime +7 -exec /bin/rm -rf '{}' \;
这个脚本是把system用户数据备份,然后压缩成TAR包,再删除备份目录下大于7天的文件