Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Cron scripts
Hi,
in the Attachment is a ksh script which takes a look in the /etc/oratab for the correct enviroment.
Ron Franks wrote:
>
> You have probably already checked this, but it your cron up and running?
> ps -ef | grep cron
>
> Later!
>
> Brian Peasland wrote:
>
> > I've been trying to create a script which I'll be executing through cron.
> > When I run the script, everything works just fine. When I schedule the
> > script through crontab, it doesn't work. And I can't see what the cron
> > script is doing. Any ideas how to find out the "output" from the run of a
> > cron script?
> >
> > Here's what I'm trying to do:
> > in a script,
> > change SID
> > sqlplus userid @script < passwordfile
> > mail results
> > do again for another SID
> >
> > The script contains a spool command to spool the results of the script to a
> > file. That file is sent to my email account. When I run this script through
> > the command line, it works just fine. When I run it through crontab, the
> > spool file is empty and I get mailed nothing. Any ideas?
> >
> > Thanks in advance,
> > Brian Peasland
> > peasland_at_msn.com
################################################################### # # usage : dbstart # # purpose : This script is used to startup the ORACLE - Databases # in /etc/oratab for the Version 7 and Version 7.3 # # parameters : none #
###################################################################
ORATAB=/etc/oratab
trap 'exit' 1 2 3
case $ORACLE_TRACE in
T) set -x ;;
esac
# Set path if path not set (if called from /etc/rc) case $PATH in
"") PATH=/bin:/usr/bin:/etc export PATH ;;
# # Loop for every entry in oratab file and and try to start # that ORACLE #
cat $ORATAB | while read LINE
do
case $LINE in
\#*) ;; #comment-line in oratab *) # Proceed only if third field is 'Y'. if [ "`echo $LINE | awk -F: '{print $3}' -`" = "Y" ] ; then ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -` if [ "$ORACLE_SID" = '*' ] ; then ORACLE_SID="" fi # Called programs use same database ID export ORACLE_SID ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -` # Called scripts use same home directory export ORACLE_HOME # Put $ORACLE_HOME/bin into PATH and export. PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc ; export PATH PFILE=${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora # Figure out if this is a V6, or V7 database if [ -f $ORACLE_HOME/bin/sqldba ] ; then VERSION=`$ORACLE_HOME/bin/sqldba command=exit | awk ' /SQL\*DBA: (Release|Version)/ {split($3, V, ".") ; print V[1]}'` else if test -f $ORACLE_HOME/bin/svrmgrl; then VERSION="7.3" fi fi if test -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.dbf -o \ -f $ORACLE_HOME/dbs/sgadef${ORACLE_SID}.ora then STATUS="-1" else STATUS=1 fi if [ -f $PFILE ] ; then case $VERSION in 6) sqldba command=startup ;; 7) sqldba <<EOF
7.3) svrmgrl <<EOF
connect internal
startup
EOF
;; esac if test $? -eq 0 ; then echo "" echo "Database \"${ORACLE_SID}\" warm started." else echo "" echo "Database \"${ORACLE_SID}\" NOT started." fi else echo "" echo "Can't find init file for Database \"${ORACLE_SID}\"." echo "Database \"${ORACLE_SID}\" NOT started." fi fi ;;
![]() |
![]() |