- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- rc=2 error on cron job
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 12:18 AM
05-26-2005 12:18 AM
rc=2 error on cron job
Can someone explain to me what I'm doing wrong or what rc=2 means?
This is what's on the cron log:
> CMD: su - oracle -c /u01/dba/oracle/product/7.3.4/bin/dbshut
> oracle 14462 c Wed May 25 23:00:00 SAT 2005
< oracle 14462 c Wed May 25 23:00:01 SAT 2005 rc=2
> CMD: su - oracle -c /u01/dba/oracle/product/7.3.4/bin/dbstart
> oracle 14719 c Thu May 26 05:00:00 SAT 2005
< oracle 14719 c Thu May 26 05:00:01 SAT 2005 rc=2
This is how the scripts look like,
dbshut:
#
# $Header: dbshut.sh.pp 07-may-97.12:04:34 mdenney Exp $ dbshut.sh.pp Copyr (c)
1991 Oracle
#
###################################
#
# usage: dbshut
#
# This script is used to shutdown ORACLE from /etc/rc(.local).
# It should ONLY be executed as part of the system boot procedure.
#
#####################################
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 ;;
esac
#
# 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
lsnrctl stop
# See if it is a V6 or V7 database
if test -f $ORACLE_HOME/bin/svrmgrl; then
svrmgrl << EOF
connect internal
shutdown
EOF
else
if test -f $ORACLE_HOME/bin/sqldba; then
VERSION=`$ORACLE_HOME/bin/sqldba command=exit | awk '
/SQL\*DBA: (Release|Version)/ {split($3, V, ".") ;
print V[1]}'`
case $VERSION in
6) sqldba command=shutdown
;;
7) sqldba <
shutdown
EOF
;;
esac
else
echo "No SQL*DBA or svrmgrl found in $ORACLE_HOME"
fi
fi
if test $? -eq 0 ; then
echo "Database \"${ORACLE_SID}\" shut down."
else
echo "Database \"${ORACLE_SID}\" not shut down."
fi
fi
;;
esac
done
dbstart:
#
# $Header: dbstart.sh.pp 1.1 95/02/22 14:37:29 rdhoopar Osd
p Copyr (c) 1991 Oracle
#
###################################
#
# usage: dbstart
#
# This script is used to start ORACLE from /etc/rc(.local).
# It should ONLY be executed as part of the system boot procedure.
#
#####################################
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 ;;
esac
#
# 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 V5, V6, or V7 database. Do we really need V5?
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"
else
VERSION="5"
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
case $STATUS in
1) if [ -f $PFILE ] ; then
case $VERSION in
5) ior w pfile=$PFILE
;;
6) sqldba command=startup
;;
7) sqldba <
startup
EOF
;;
7.3) svrmgrl <
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
;;
-1) echo ""
echo "Database \"${ORACLE_SID}\" possibly left running when
system went down (system crash?)."
echo "Notify Database Administrator."
case $VERSION in
5) ior c
;;
6) sqldba "command=shutdown abort"
;;
7) sqldba <
shutdown abort
EOF
;;
7.3) svrmgrl <
shutdown abort
EOF
;;
esac
if test $? -eq 0 ; then
if [ -f $PFILE ] ; then
case $VERSION in
5) ior w pfile=$PFILE
;;
6) sqldba command=startup
;;
7) sqldba <
startup
EOF
;;
7.3) svrmgrl <
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_S
ID}\"."
echo "Database \"${ORACLE_SID}\" NOT started."
fi
else
echo "Database \"${ORACLE_SID}\" NOT started."
fi
;;
esac
fi
;;
esac
lsnrctl start
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 12:23 AM
05-26-2005 12:23 AM
Re: rc=2 error on cron job
Those return codes are coming from the Oracle supplied dbstar/stop scripts - not from your cron entries. Your best bet would be to examine the oracle alert log to find out if there's anything amiss going on there. Failing that, a message to comp.databases.oracle.misc would probably get you better support than from the HP forum.
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 12:23 AM
05-26-2005 12:23 AM
Re: rc=2 error on cron job
cron scripts run with a very minimal environment.
You should be putting all required variables in your script itself.
Do the scripts run fine manually??
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 12:25 AM
05-26-2005 12:25 AM
Re: rc=2 error on cron job
If so, the error is not something you need to worry about. If not, you probably have an environment problem.
If the script works from the command line and not cron then the environment shown by the env command is different and Oracle doesn't like it.
I found the dbshut command so ineffective, because it doesn't do a shutdown immediate, I re-wrote it and replaced it. My replacement always seemed to get a non-zero return code. The good news is it shut the database so I was happy and moved on to other issues.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 12:29 AM
05-26-2005 12:29 AM
Re: rc=2 error on cron job
How can I verify that they ran indeed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 12:58 AM
05-26-2005 12:58 AM
Re: rc=2 error on cron job
#!/bin/ksh
set -x
# dbshut.sh
... code
..
# set +x
In cron,
x x x x x script 1>/tmp/dbshut.log 2>&1
Check /tmp/dbshut.log file.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 01:02 AM
05-26-2005 01:02 AM
Re: rc=2 error on cron job
env > /tmp/$$.txt
After a cron run and a command line run.
cd /tmp
ls *.txt
diff the two files.
When the environment is the same, it will work the same in cron as the command line. Don't be afraid to set the TERM variable. Oracle is very sensitive about environment.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 01:09 AM
05-26-2005 01:09 AM
Re: rc=2 error on cron job
i had a similar problem as your few months
ago on my DP5.0 post&pre execution scripts
for to purpose Automated offline bcks and
i needed to shutdown&statup my ORacle 9i...
Normally my scripts were working from command
but when i have put these scripts from DP omniback onto pre-exec,post-exec then
failed so i discovered that i did not define
my env settings in these script like;
#!/usr/bin/ksh
ORACLE_HOME=/oracle/9.2.0
export ORACLE_USER=oracle
PATH=${ORACLE_HOME}/bin:/sbin:/usr/bin:/usr/sbin:/etc:/bin
export ORACLE_HOME
When i have put then it worked...
Good Luck,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 05:18 AM
05-26-2005 05:18 AM
Re: rc=2 error on cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 05:26 AM
05-26-2005 05:26 AM
Re: rc=2 error on cron job
Its calling a Kornshell to execute your script...
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 05:28 AM
05-26-2005 05:28 AM
Re: rc=2 error on cron job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 06:33 AM
05-26-2005 06:33 AM
Re: rc=2 error on cron job
kcspecdp # at -f /u01/dba/oracle/product/7.3.4/bin/dbshut 1530
warning: commands will be executed using /usr/bin/sh
job 1117137600.a at Thu May 26 15:30:00 2005
Will at be "similar" to cron in terms of being able to watch what happens?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 06:45 AM
05-26-2005 06:45 AM
Re: rc=2 error on cron job
in terms of monitoring at jobs, they are logged in the same cron log and will send output via email in exactly the same way a cron job would.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 07:41 AM
05-26-2005 07:41 AM
Re: rc=2 error on cron job
Other than that seems to be working fine.
Thanks all
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2005 08:44 PM
05-26-2005 08:44 PM
Re: rc=2 error on cron job
In this case, write yourself a script or check your equivalent start/stop script that should be in /sbin/init.d
Lets say rc.oracle...
This is what I have in one of my 10.20 rc.oracle :
#!/usr/bin/ksh
export ORACTI_EXPLOIT=/opt/oracle/admin/exploit
export PATH=$PATH:/usr/bin:$ORACTI_EXPLOIT/proc
case "$1" in
start_msg)
echo "Start Oracle"
;;
stop_msg)
echo "Stop Oracle"
;;
start)
$ORACTI_EXPLOIT/proc/db_start
su - oracle -c $ORACTI_EXPLOIT/proc/net_start
;;
stop)
su - oracle -c $ORACTI_EXPLOIT/proc/net_stop
$ORACTI_EXPLOIT/proc/db_shut
;;
*)
echo "usage: $0 {start|stop}"
#rval=1
;;
esac
#End
Motice that this script start AND stops the listener also, so do the same
Now if this script does exactly what you want , then use it in your cronfile:
00 21 * * * /sbin/init.d/rc.oracle stop>>/sm/cron/log/cron_oracle.log 2>&1
00 05 * * * /sbin/init.d/rc.oracle start >>/sm/cron/log/cron_oracle.log 2>&1
I have created on most system here a separate filesystem: /sm with loads of sub like cron bin logs depot doc where is kept all that I believe is important for the sysadmins...
Here you would have now in /sm/cron/log the output from your cron execution so the information is quickly accessible without big search...
The problem will arise if you have more than on instance though... (Youve stopped the listener remember?...)
Now I wrote all this I have under my eyes maybe an explanation:
Someone will need to confirm (Still wearing bad glasses..)
At the end of your script:
...
.
.
else
echo "Database \"${ORACLE_SID}\" NOT started."
fi
;;
esac
fi
;;
esac
lsnrctl start #<--- You start the listener
done # But where do you stop it?....
So this script seems to work the first time but then at each call you may well have the listener still running... Explaining your error...
All the best
Victor