创建expdp.sh脚本
注意:脚本中需要对环境变量进行设置,否则crontab无法正常运行
#!/bin/bash
PATH=$HOME/bin:/u01/app/oracle/product/10.2.0/db_1/bin:$PATH
export ORACLE_SID=prod
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH
dmp_file=scott_`date +%Y%m%d_%H%M%S`.dmp
log_file=scott_`date +%Y%m%d_%H%M%S`.log
expdp scott/scott@prod schemas=scott directory=dir dumpfile =$dmp_file logfile=$log_file;
-------------------------------------------------------------------------------------------------------------------------------------------
将脚本加入到crontab中
注意:crontab中的%是换行的含义,需要用\转意
crontab –e
0 23 * * * sh /home/oracle/scripts/bin/expdp.sh>/home/oracle/scripts/log/expdp_scott_`date +\%Y\%m\%d_\%H\%M\%S`.log 2>&1来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29424472/viewspace-1255631/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29424472/viewspace-1255631/