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

From: sundar mahadevan <>
Date: Mon, 27 Jun 2011 15:46:04 -0400
Message-ID: <>

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/ invest1

#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_HOME=`cat /etc/oratab | grep ${TARGET_SID}: | grep -v "^#" | cut -d : -f 2`

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
EOF cat test.log
OS->escenic OH->/u01/app/oracle/11gse1

On Mon, Jun 27, 2011 at 2:48 PM, Bill Zakrzewski <> 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.
> >
> >
> > #!/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

Received on Mon Jun 27 2011 - 14:46:04 CDT

Original text of this message