RE: cannot spool the mounted standby database through cron job shell script. Any other suggestions?

From: Michael Dinh <mdinh_at_XIFIN.Com>
Date: Mon, 27 Jun 2011 13:04:29 -0700
Message-ID: <D29F9902E534D5478F2E83FD6A44B3063B039D4F8F_at_mail02.mba.xifin.com>



Replace with
#!/bin/bash -x
$ORACLE_HOME/bin/sqlplus -s /nolog << EOF (full path to SQL*Plus)

Replace with
40 15 * * * /app/oracle/sm/test.sh invest1 > /u01/app/oracle/cron.log 2>&1

Does this work and what does cron.log shows if it doesn't?

Michael Dinh

NOTICE OF CONFIDENTIALITY - This material is intended for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable laws. BE FURTHER ADVISED THAT THIS EMAIL MAY CONTAIN PROTECTED HEALTH INFORMATION (PHI). BY ACCEPTING THIS MESSAGE, YOU ACKNOWLEDGE THE FOREGOING, AND AGREE AS FOLLOWS: YOU AGREE TO NOT DISCLOSE TO ANY THIRD PARTY ANY PHI CONTAINED HEREIN, EXCEPT AS EXPRESSLY PERMITTED AND ONLY TO THE EXTENT NECESSARY TO PERFORM YOUR OBLIGATIONS RELATING TO THE RECEIPT OF THIS MESSAGE. If the reader of this email (and attachments) is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. Please notify the sender of the error and delete the e-mail you received. Thank you. From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of sundar mahadevan Sent: Monday, June 27, 2011 12:46 PM
To: Oracle-L_at_freelists.org
Subject: Re: cannot spool the mounted standby database through cron job shell script. Any other suggestions?

Hi All,
Thanks for the response. Here is the complete script. I did set the oracle_sid and oracle_home. There are no error messages. The spool file does not get created. If i run it from command prompt, i am able to get the spool file created. I tested this on 11gse1(linux) as well as 10gr2 EE(AIX). Also i tested this on a open database and even it does not create the file. So this has nothing to do with the status of the database. Can someone try it out for me and let me know if you are facing the same issue. I have all permissions to write/create files on the directory.

This is how my cronjob looks: 40 15 * * * /app/oracle/sm/test.sh invest1

#!/bin/bash
#sqplus will return last archive log applied result to the screen if manually run

SCRIPT_DIR=/u01/app/oracle/admin/escenic/standby FULL_LOG_NAME=${SCRIPT_DIR}/test.log

export TARGET_SID="$1"
export TARGET_SID=`echo ${TARGET_SID} | sed -e 's/ //g'`
export TARGET_SID=`cat /etc/oratab | grep -i "${TARGET_SID}:"  | grep -v "^#" | cut -d : -f 1`
export ORACLE_SID=${TARGET_SID}
export ORACLE_HOME=`cat /etc/oratab | grep ${TARGET_SID}: | grep -v "^#" | cut -d : -f 2`

echo "OS->${ORACLE_SID} OH->${ORACLE_HOME}" >> ${FULL_LOG_NAME} cd ${SCRIPT_DIR}
echo "PWD"`pwd` >> ${FULL_LOG_NAME}
echo "" >> ${FULL_LOG_NAME}
sqlplus -s /nolog << EOF
set head off
connect / as sysdba
spool abcd.log
select max(sequence#) max_seq from v\$log_history; spool off
quit
EOF cat test.log
OS->escenic OH->/u01/app/oracle/11gse1
PWD/u01/app/oracle/admin/escenic/standby On Mon, Jun 27, 2011 at 2:48 PM, Bill Zakrzewski <bill_at_intactus.com<mailto:bill_at_intactus.com>> wrote: What is the exact error you are getting?

On Jun 27, 2011, at 2:10 PM, sundar mahadevan wrote:

> Hi All,
> Greetings. I have a standby in mount state. I would like to query the latest archive log applied on standby (in mount state) to apply the archive logs from primary with a cron job shell script. When i query "select max(sequence#) from v\$log_history;" from a shell script it works. But if i set it up as cron job as below, it does not work. I cannot assign the output to a shell variable since the database is not open and it would crap out. Any other suggestions? And the reason for this behaviour? Thanks a lot in advance.
>
> test.sh
> #!/bin/bash
> sqlplus -s /nolog << EOF
> set head off
> connect / as sysdba
> spool last_applied_on_standby.log
> select max(sequence#) from v\$log_history;
> spool off
> quit
> EOF

--
http://www.freelists.org/webpage/oracle-l
Received on Mon Jun 27 2011 - 15:04:29 CDT

Original text of this message