LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 11-16-2012, 05:25 PM   #1
BMMadhav
LQ Newbie
 
Registered: Nov 2012
Posts: 1

Rep: Reputation: Disabled
Post ShellScript executed from command prmpt but not executed from crontab or at command


Hi All,

I have an issues running a shell script which contains Plsql Script from crontab or at(Command).

1)Script*************
#!/usr/bin/ksh
PATH=$PATH:/bin:/usr/bin
. /opt/admin/home/oracle/.profile


Trans_Comp_Cleanup()
{
sqlplus -s USERNAME/PASSWORD << EOM > Trans_Comp_Cleanup.log
set verify off
set heading off
set feedback off
SET serveroutput ON;
DECLARE

CURSOR processInstCur
IS
select * from comp_availability where create_dt < sysdate -90
and rownum < 2;

cur_count NUMBER := 0;
Duplicate VARCHAR2(2000) := 'NONE';

BEGIN
DBMS_OUTPUT.ENABLE (2000000);
DBMS_OUTPUT.PUT_LINE('Deleting records For Orders...');
FOR Cur_Loop IN processInstCur
LOOP

DELETE comp_availability
WHERE TRANSACTION_ID = Cur_Loop.TRANSACTION_ID
and create_dt < sysdate -90;


DELETE tran_availability
WHERE TRANSACTION_ID = Cur_Loop.TRANSACTION_ID
and create_dt < sysdate -90;



IF (Duplicate = 'NONE' OR Duplicate != Cur_Loop.TRANSACTION_ID) THEN
Duplicate := Cur_Loop.TRANSACTION_ID;
dbms_output.put_line (Cur_Loop.TRANSACTION_ID );

cur_count := cur_count +1;
END IF;



END LOOP;
COMMIT;
dbms_output.put_line ('Deleted ' || cur_count || ' Orders ');
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line ('Exception occurred : ' || SQLCODE || ' : ' || SQLERRM);
END;
/
EOM
}
Trans_Comp_Cleanup

echo Executed
at -f Trans_Comp_Cleanup.sh 11:00AM saturday

2)Entry in Crontab************* :
58 15 * * * /opt/admin/home/oracle/Trans_Comp_Cleanup.sh

I tried checking some posts but I was not able to resolve this issue.I think this is issue with environment.But was not able to resolve.
Any help is much appreciated.
 
Old 11-16-2012, 08:20 PM   #2
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 659

Rep: Reputation: 160Reputation: 160
Mostly path and rights issues since through crontab, which is executed as a super user may not have rights to oracle paths and directories.

This can be verified by redirecting the error messages (2&) of the shell script to a file and viewing the output.

Things to try.
(1) Change the path statement in the beginning of your script to include oracle paths for the executables like splplus
(2) Ensure that all the directories requiring access by oracle permit access by users outside of the oracle group.

If it still doesn't work, use an oracle feature.
I just got this by ggogling.
http://asktom.oracle.com/pls/asktom/...d:388480262167

OK

Last edited by AnanthaP; 11-16-2012 at 08:26 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"ps" command not executed in script when using crontab Annielover Linux - General 6 06-06-2011 03:22 PM
time when a command was executed. anandkj Linux - Newbie 3 12-21-2007 02:09 AM
how to see which command has been executed ? Volcano Linux - Newbie 4 12-11-2006 09:48 AM
which command executed on which terminal dsids Linux - Newbie 1 09-23-2006 09:57 AM
How do I undo last command executed? Elfking Linux - General 4 02-05-2004 02:18 AM


All times are GMT -5. The time now is 03:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration