Script errors out only when its executed via job


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script errors out only when its executed via job
# 1  
Old 03-26-2009
Script errors out only when its executed via job

I wrote a script to shutdown the oracle database. The script works fine when I manually run the script. However, when i schedule a job, i get the following error.

Shutting Down cmismart ....................
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SVR4 Error: 2: No such file or directory

HERE IS MY SCRIPT



#!/bin/ksh
#Purpose: This script will shudown oracle.
###############################################################################


###Shutting down database
shutdown_db()
{
sqlplus -s / as sysdba <<END
WHENEVER SQLERROR EXIT FAILURE
set echo off newpage 0 space 0 pagesize 0 feed off head off
SHUTDOWN IMMEDIATE
END
return $?
}


NOW=`date +"%d%m%y"`
ERRLOG=$NOW"_err.log"
export ORACLE_HOME=/home/oracle/product/10.2.0/db_1
export ORACLE_SID=cmismart
export PATH=$PATH:$ORACLE_HOME/bin

touch $ERRLOG
echo "Shutting Down $ORACLE_SID ...................."
if shutdown_db
then
DBPROCESS=`ps -ef | grep ${ORACLE_SID} | grep pmon | wc -l`
if [ $DBPROCESS -eq 0 ]
then
echo "$ORACLE_SID has been successfully shutdown."
else
echo "$An error occured while trying to shutdown $ORACLE_SID" >> ./$ERRLOG
fi
else
echo "Error occured while shutting down $ORACLE_SID." >> ./$ERRLOG
fi

Last edited by mrx1350; 03-26-2009 at 01:15 PM..
# 2  
Old 03-26-2009
check this

the issue might be due to oracle_sid

OTN Discussion Forums : ORA-27101: shared memory realm does not ...
# 3  
Old 03-26-2009
In my ORACLE_HOME where you have "product" I have "products".
Please check the value of ORACLE_HOME
# 4  
Old 03-26-2009
Quote:
Originally Posted by methyl
In my ORACLE_HOME where you have "product" I have "products".
Please check the value of ORACLE_HOME
Yes the oracle home is correct.
# 5  
Old 03-26-2009
Quote:
Originally Posted by amitranjansahu
check this

the issue might be due to oracle_sid

OTN Discussion Forums : ORA-27101: shared memory realm does not ...
Its not the oracle_sid. Again, this script works find when I execute it manually. The only time it erros out is if I have the unix job run it.
# 6  
Old 03-26-2009
check the man page of crontab.This is what i got from net
========================================

Crontab Environment
___________
cron invokes the command from the user's HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh

Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.
# 7  
Old 03-26-2009
Make sure that your cron is running as user "oracle" or from a root cron with syntax:
su - oracle -c "scriptname params".
See system supplied script ${ORACLE_HOME}/bin/dbshut and make sure that you have everything in your script to match your version of Oracle. The system script may not have "shutdown immediate" but otherwise all the elements should be there.
The system scripts positively set PATH rather than appending to the system PATH.
To find out your environment under cron try a single line cron containing say only "env >/tmp/env$$.txt" , then repeat this as from cron as user oracle.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to detect and fix why crontab job is not executed?

I have set several cron jobs. I recently added a new cron job that copies a file of last day from another server and is executed each day (for example at 04:00 am) but when I check next day the file hasn't been copied. I'm working in GNU/Linux CentOS (2.6.32) system. The files that I need to... (23 Replies)
Discussion started by: Ophiuchus
23 Replies

2. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

3. Shell Programming and Scripting

Shell script executed from Informatica ETL tool is spawning 2 processes for one script

Hi, I am having a shell script which has a while loop as shown below. while do sleep 60 done I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Discussion started by: chekusi
2 Replies

4. UNIX for Dummies Questions & Answers

Cron job executed at wrong time

Dear *nix users. I'm on Mac OS 10.6 / Terminal and try to use crontab to schedule two scripts every 30 minutes and every 41 minutes. I followed the man instructions and created / installed a crontab file for the current user:crontab -e with the following content */30 * * * *... (4 Replies)
Discussion started by: moxnos
4 Replies

5. Shell Programming and Scripting

crontab job not executed with variables

Hi, I am trying to execute a script (for once) during the booting time in Ubuntu system. However, the result is only showing the strings without without the variables. Here is the script: MgrIp=$(ec2-describe-instances --filter tag:Name=Mgr --filter instance-state-name=running | egrep... (4 Replies)
Discussion started by: turki_00
4 Replies

6. AIX

Script not getting executed via cron but executes when executed manually.

Hi Script not getting executed via cron but executes successfully when executed manually. Please assist cbspsap01(appuser) /app/scripts > cat restart.sh #!/bin/ksh cd /app/bin date >>logfile.out echo "Restart has been started....." >>logfile.out date >>logfile.out initfnsw -y restart... (3 Replies)
Discussion started by: samsungsamsung
3 Replies

7. Shell Programming and Scripting

Script to Start a Job after finding the Old job completed

Hi Experts, I need a script advice to schedule 12 jobs ( SAS Codes execute back ground ). Algorithem: 1. Script checks first job. 2. Finds first job is done; invoke second job. 3. finds second job is done; invoke third job. .. Request you to please assist. (3 Replies)
Discussion started by: Jerald Nathan
3 Replies

8. UNIX and Linux Applications

Log files to view job executed in Autosys -- Help ASAP

Hi all, I really need your help ASAP on this. Below is the description of my problem and a sketch of Autosys Job Activity Console ++++++++++++++++++++++++++++++++ File View Options +++++++++++++++++++++++++++++++ Job Name Description Status Command Machine... (1 Reply)
Discussion started by: sakal_woman
1 Replies

9. Shell Programming and Scripting

ant not being executed as cron job

i have a script that uses an ant build.xml and its targets to pull a project from a cvs server, attempt to build the project, and then email me the results. When I run the script (either @ CLI or as a cron job) while I am logged in, everything works fine. However, if the script is set up to run... (5 Replies)
Discussion started by: kingfinny
5 Replies

10. UNIX for Dummies Questions & Answers

errors when running a cron job

I am running some shell scripts through a foll cron job, the script works fine and there are no errors in the log file but I receive the following error in mail for the jobs: stty: no such device or address What does the above error indicate, here is the cron job: 0 22 * * 0... (2 Replies)
Discussion started by: knarayan
2 Replies
Login or Register to Ask a Question