Hi Experts,
Am facing some problems with script (Sun solaris 9). My script (sqlplus.sh)looks like this. . .
...............................................
set 'date'
dd=$3
export dd
mon=$2
export mon
yyyy=$6
export yyyy
cd /oracle/P47/saparch
LOG_FILE=/oracle/P47/saparch/archive_today_$yyyy$mon$dd.log
echo "*******************************************************************">> $LOG_FILE
date >> $LOG_FILE
sqlplus "/as sysdba"<< EOF >> $LOG_FILE
set serveroutput on ;
set time on ;
recover automatic standby database;
CANCEL
exit
EOF
echo "Finish applying archives in SAP DR site..." >> $LOG_FILE
echo " ----------------------------------------------------------">> $LOG_FILE
echo "End SAP DR script " >> $LOG_FILE
echo "=========================================================" >> $LOG_FILE
mailx -s "LOG - SAP DR applying archives $dd$mm$yy..." vrjalli@xyz.com < $LOG_FILE
...............................................................................................
My problems are
- When I run manually (with command: sh sqlplus.sh) it is working fine. But when i schedule in cron it is not working.
- Mails are not coming.
- Log file is coming without date stamp.(archive_today_.log)
Please help. . .
rgds
When you say its not working what is the error received ?
modify your cron entry to
script > logfile 2>&1
and instead of using just sqlplus
use the absolute path of the sqlplus as user's profile is not implicitly loaded to cron unless done explicitly
Hi matrixmadhan,
Thanks for ur reply!!!!
my script parh is: /oracle/SID/saparch/sqlplus.sh
and cron entry is:
30 10,13,15,17,19,21 * * * /oracle/P47/saparch/sqlplus.sh
and I hv given 777 permisions to sqlplus.sh file.
rgds
Ok. After using absolute pathname what is cron saying after executing ?
Post the error message if there are any such !
Am not getting any error simply it is not executing. . . . .
my script parh is: /oracle/P47/saparch/sqlplus.sh
and cron entry is:
30 10,13,15,17,19,21 * * * /oracle/P47/saparch/sqlplus.sh
but when my pwd is: /oracle/P47/saparch
it is working with command: sh sqlplus.sh
rgds
Hi Matrixmadhan,
Actually when i try ps -ef | grep
I recd message that there is a mail in /var/mail/root and the contents are as below
Date: Tue, 15 Jan 2008 17:31:00 +0530 (IST)
From: Super-User <root@ttmlpunesun>
Message-Id: <200801151201.m0FC10GB024886@ttmlpunesun>
To: root@ttmlpunesun
Subject: Output from "cron" command
MIME-Version: 1.0
Content-Type: text/plain
Content-Length: 148
Your "cron" job on ttmlpunesun
/oracle/P47/saparch/sqlplus.sh
produced the following output:
/oracle/P47/saparch/sqlplus.sh: sqlplus: not found
.................................................................................
rgds
What the cron job mail is saying is that your script is not finding the sqlplus execuble
You need to modify the line
sqlplus "/as sysdba"
to include the full pathname to sqlplus.
It is always good practice to include full pathnames in all shell scripts invoked via cron.
Also what is the shebang line in the script ( the first line ) ?