Sponsored Content
Operating Systems AIX SH Script Execution Problems with Cronjob Post 302535172 by lodhi1978 on Thursday 30th of June 2011 03:29:03 AM
Old 06-30-2011
Question SH Script Execution Problems with Cronjob

Hi,

I have created a sh script to startup and shutdown the oracle database, when I execute the script thru command line it execute successfully, but when I call the script thru cronjob it does not execute.

The scripts are as follows:
Code:
 
LOG=/oracle/times.log
export ORACLE_SID=prod
echo $ORACLE_SID" Standby Database Open READ ONLY initiated   " `date` >> $LOG
sqlplus "/as sysdba"<<EOF
recover managed standby database cancel;
shutdown immediate;
startup mount;
alter database open read only;
EOF
echo $ORACLE_SID" Standby Database Open READ ONLY completed   " `date` >> $LOG

Code:
 
LOG=/oracle/times.log
export ORACLE_SID=prod
echo $ORACLE_SID" Standby Database Close READ ONLY initiated  " `date` >> $LOG
sqlplus "/as sysdba"<<EOF
shutdown immediate;
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;
EOF
echo $ORACLE_SID" Standby Database Close READ ONLY completed  " `date` >> $LOG
echo $ORACLE_SID" Standby Database Recovery Mode Started      " `date` >> $LOG
echo "===============================================================================" >> $LOG

Cron job is as follows:

Code:
 
00 0,9,12 * * * sh /oracle/scripts/standby_open_reporting.sh
00 2,21,13 * * * sh /oracle/scripts/standby_close_reporting.sh


Below is output of times.log file

Code:
prod Standby Database Close READ ONLY initiated   Wed Jun 29 21:00:00 PKST 2011
prod Standby Database Close READ ONLY completed   Wed Jun 29 21:00:00 PKST 2011
prod Standby Database Recovery Mode Started       Wed Jun 29 21:00:00 PKST 2011
===============================================================================
prod Standby Database Open READ ONLY initiated    Thu Jun 30 00:00:00 PKST 2011
prod Standby Database Open READ ONLY completed    Thu Jun 30 00:00:00 PKST 2011
prod Standby Database Close READ ONLY initiated   Thu Jun 30 02:00:00 PKST 2011
prod Standby Database Close READ ONLY completed   Thu Jun 30 02:00:00 PKST 2011
prod Standby Database Recovery Mode Started       Thu Jun 30 02:00:00 PKST 2011
===============================================================================
prod Standby Database Open READ ONLY initiated    Thu Jun 30 09:00:00 PKST 2011
prod Standby Database Open READ ONLY completed    Thu Jun 30 09:00:00 PKST 2011


Last edited by lodhi1978; 06-30-2011 at 04:36 AM.. Reason: adding log file output
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cronjob problems...

Hi All! I have a problem with one of my scripts. When I run the script from the command line : ./myscript.mac, it runs fine, but when I schedule it to run as a cronjob I get the following error : ----------------------------------------------------------------------------- Your "cron" job... (5 Replies)
Discussion started by: Jacovanderberg
5 Replies

2. Shell Programming and Scripting

Problems in running a Perl script via cronjob

I have a very basic perl script that attempts to find if a process is running. If the process is not running then the script is supposed to start the process. If I execute the script from command line it works fine as expected. However if the script is executed via cronjob, the script cannot find... (1 Reply)
Discussion started by: ypant
1 Replies

3. OS X (Apple)

Execution Problems with ASU Shell Script

Hello. I have been trying to create a shell script that checks to see if there are software updates and if not, then exit the script. If so, then check to see if a user is logged in. If a user is logged in, it will only install the updates. If a user is not logged in, then it will display a... (3 Replies)
Discussion started by: Talcon
3 Replies

4. Shell Programming and Scripting

Execution Problems with bash script

Hello, can someone please help me to fix this script, I have a 2 files, one file has hostname information and second file has console information of the hosts in each line, I have written a script which actually reads each line in hostname file and should grep in the console file and paste the... (8 Replies)
Discussion started by: bobby320
8 Replies

5. Shell Programming and Scripting

Execution Problems!!

i have been working on this for a about 12 hours today say's end of file un expected any idea's using the bourne shell and its driving me nuts worked fine in bash but prof says make it work in bourne and good luck worth 13% any help would be awesome #!/bin/sh trap "rm mnt2/source/tmp/* 2>... (1 Reply)
Discussion started by: mrhiab
1 Replies

6. Shell Programming and Scripting

Execution problems with BASH Shell Script

Hi I need help with my coding , first time I'm working with bash . What i must do is check if there is 3 .txt files if there is not 3 of them i must give an error code , if al three is there i must first arrange them in alphabetical order and then take the last word in al 3 of the .txt files... (1 Reply)
Discussion started by: linux newb
1 Replies

7. Shell Programming and Scripting

Execution Problems

this my source file ************* fixed *************** Begin equipmentId : d9 processor : fox number : bhhhhhh Variable # 1: Id : 100 Type : 9 nType : s gType : 5f mType : 4 LField : England DataField : london Length ... (6 Replies)
Discussion started by: teefa
6 Replies

8. Shell Programming and Scripting

Expect script Execution Problems .. Help!!!

Hi Guys, I am writing the expect script which take input from the txt file and check whether that file is present over the Sftp or not.If yes then delete other wise check the next one.. I am able to do comparison online for single file... Please also note still i didn't try to implement... (1 Reply)
Discussion started by: hackerdilli
1 Replies

9. UNIX for Dummies Questions & Answers

Execution Problems with Cron

Good evening, ive got this cron to be run: if i run this manually it doesnt work,it takes me to the prompt again /export/app/CO/opge/scr/Informe_parametros_colombia.ksh >/dev/null 2>&1 here is the code fragment: coopge@coopge: opge PRODUCCION>more... (1 Reply)
Discussion started by: alexcol
1 Replies

10. UNIX for Beginners Questions & Answers

Execution problems

How to find a word in a directory which contains many files? i just want to count how many such words are present in all the files? This is the code which i tried for a single file echo "Enter the file name:" read file echo "Enter the word to search:" read word if then echo "The count... (4 Replies)
Discussion started by: Meeran Rizvi
4 Replies
All times are GMT -4. The time now is 05:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy