LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 04: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, 07:20 PM   #2
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Posts: 952

Rep: Reputation: 217Reputation: 217Reputation: 217
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 07:26 PM.
 
  


Reply



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 10 08-10-2018 01:00 AM
time when a command was executed. anandkj Linux - Newbie 3 12-21-2007 01:09 AM
how to see which command has been executed ? Volcano Linux - Newbie 4 12-11-2006 08:48 AM
which command executed on which terminal dsids Linux - Newbie 1 09-23-2006 08:57 AM
How do I undo last command executed? Elfking Linux - General 4 02-05-2004 01:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:00 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
Open Source Consulting | Domain Registration