1

I have a cronjob scheduled to be executed every morning at 1.25 am. The script suppose to delete the archive logs created in Oracle DB for the previous day. But it is not executing as expected. But when I execute it manually in the command prompt it executes and delete the archive logs as expected. I hope the problem is when the script connecting to RMAN as a cronjob. But I dont know how to solve it pls help me on this. Following are the things I use

The OS is Susei linux

cron is scheduled as below

25 01 * * * /x01/rman_backup/mahesh/logde.sh

Contents in logde.sh

ORACLE_HOME=/x01/oracle/app/oracle/product/11.2.0/db_1
ORACLE_SID=sec
PATH=$ORACLE_HOME/bin:$PATH

/x01/oracle/app/oracle/product/11.2.0/db_1/bin/rman cmdfile=/x01/rman_backup/mahesh  /logdelete.rcv

contents in the logdelete.rcv

connect target /
run
{
delete archivelog all completed before 'trunc(sysdate)';
crosscheck archivelog all;

}
exit;
user1793864
  • 241
  • 2
  • 6
  • 13

1 Answers1

-1

You must use EXPORT to set environment variables, otherwise environment will not set

export ORACLE_HOME=/x01/oracle/app/oracle/product/11.2.0/db_1
export ORACLE_SID=sec
export PATH=$ORACLE_HOME/bin:$PATH

Also i would suggest to use in which shell you want to execute by mentioning sh or ksh

25 01 * * * sh /x01/rman_backup/mahesh/logde.sh

Please check below URL for more info https://oracle-base.com/articles/misc/oracle-shell-scripting