首页 > 代码库 > 有crontab中的脚本不执行,需要在脚本里面export各种环境变量
有crontab中的脚本不执行,需要在脚本里面export各种环境变量
[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各种环境变量