0

I have a problem with script scheduled in cron. In cron I have following line:

33 09 * * 1-5 oracle /data1/backup/scripts-test/rman.sh > /data1/backup/log.txt 2> /data1/backup/log_err.txt

As you see I have to use oracle user to run rman script. RMAN.SH looks as follow:

#!/bin/bash
ORACLE_HOME="/data1/app/oracle/product/12.1.0.2/db_1"
ORACLE_SID="eelxtest"
PATH=$ORACLE_HOME/bin:$PATH
now="$(date)"
logloc="/data1/backup/scripts-test/log"
rmanscript="/data1/backup/scripts-test"
jboss="/usr/JBossEAP/jboss-eap-6.4/bin"
ip="x.x.x.x"
ServerGroup="EELX-Server-Group-Test"
logfile="$logloc/$(date '+%Y-%m-%d')_log.txt"
echo "============================================" | tee -a "$logfile"
date | tee -a "$logfile"
echo "STEP1 closing JBoss Server Group" | tee -a "$logfile"
$jboss/jboss-cli.sh --controller=$ip --connect /server-group=$ServerGroup:stop-servers | tee -a "$logfile"
echo "STEP2 oracle backup. See rman log." | tee -a "$logfile"
**$ORACLE_HOME/bin/rman msglog /data1/backup/scripts-test/log/$(date '+%Y-%m-%d')_rman.log cmdfile=$rmanscript/rman_backup.cmd**
echo "STEP3 starting jboss Server Group" | tee -a "$logfile"
$jboss/jboss-cli.sh --controller=$ip --connect /server-group=$ServerGroup:start-servers | tee -a "$logfile"]

rman_backup.cmd is:

connect target /
shutdown immediate;
startup mount;
run
{
allocate channel ch1 device type disk;
backup as compressed backupset full database format '/data1/extDirectories/xxx/yyy/oracle/test/%T_eelxtest_full_%u.bkp';
backup format '/data1/extDirectories/xxx/yyy/oracle/test/%T_archivelog_eelxtest_%u.bkp' >>(archivelog all delete input);
backup spfile;
backup current controlfile format '/data1/extDirectories/xxx/yyy/oracle/test/%T_ora_ctl_file_eelxtest_%u.bkp';
release channel ch1;
}
sql 'alter database open'

As a result of job in cron are following messages:

Message file RMAN<lang>.msb not found
Verify that ORACLE_HOME is set properly

So I have verified ORACLE_HOME on both profiles oracle and root and it is in place in .bash_profile. Furthermore there is nothing mentioned in rman trace or log because rman didn't start at all.

Please help.

  • Does export ORACLE_HOME help? – Patrick Jan 27 '17 at 11:29
1

Thomas,

possible you must export the variable ORACLE_HOME, by;

export ORACLE_HOME

after declaration in script: rman.sh

  • when running script in cron, you have less environment. – Paulus Jan 27 '17 at 11:52
  • yes, you are right. Missing export. Thank you – KUE Jan 27 '17 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.