码迷,mamicode.com
首页 > 其他好文 > 详细

有crontab中的脚本不执行,需要在脚本里面export各种环境变量

时间:2014-09-09 15:46:28      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:io   ar   art   cti   sp   log   on   c   amp   

[oracle@sta ~]$ vi .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export PATH
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1/
ORACLE_SID=jg
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
~
~
[oracle@sta ~]$ crontab -l
*/30 * * * * /opt/jj/system.sh
30 11,17 * * * /opt/jj/oracle.sh
0 0 */3 * * /u01/oracle/exp.sh
30 4 * * * /opt/jj/back.sh
#0 4 * * * /opt/jjbak/scripts/jjbak.sh
0 4 * * * sh /u01/oracle/hydir/jjbak.sh >> /u01/oracle/oydir/oy.log &


[oracle@sta ~]$ cat /u01/oracle/hydir/jjbak.sh
#!/bin/sh
echo ‘backup start!‘
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1/
export ORACLE_SID=jg
/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target / <<EOF!
backup incremental level=1 database;
recover copy of database;
quit
EOF!
echo "image copy success!"
/u01/app/oracle/product/11.2.0/dbhome_1/bin/sqlplus / as sysdba <<EOF!
CREATE PFILE=‘/opt/jjbak/pfile/pfilejg.ora‘ from spfile ;
quit
exit
EOF!
echo ‘backup success!‘
[oracle@sta ~]$

有crontab中的脚本不执行,需要在脚本里面export各种环境变量

标签:io   ar   art   cti   sp   log   on   c   amp   

原文地址:http://www.cnblogs.com/taosim/p/3962544.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!