Solved

Invoke Shell script using dbms_scheduler

Posted on 2011-03-15
3
1,164 Views
Last Modified: 2012-05-11
I am using dbms_scheduler to invoke a shell script. The shell script requires one input parameter.

begin
   dbms_scheduler.create_job
   (
      job_name                  => 'DEMO_SHELL_JOB',
      job_type                  => 'EXECUTABLE',
      job_action                => '/home/test/test.sh',
      number_of_arguments       => 1,
      start_date            => sysdate + 10/1440,
      enabled                   => false,
      auto_drop                 => true,
      comments                  => 'Run shell-script'
   );
end;
/

Enabled => false because the argument needs to be provided before I enable the job.
I am providing the argument as below:
begin
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
   job_name                  => 'DEMO_SHELL_JOB',
   argument_position            => 1,
   argument_value            => '/usr/tmp/abc.trc');
end;
/

I am stuck here.. Can you point how to enable the job again..
My requirement is to run the shell script once for the input argument that I provide. I also want the job to be dropped after it executes (auto_drop=> true).
Am I doing it the correct way..

Thanks in advance...
0
Comment
Question by:sanpradeep
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 250 total points
ID: 35144942
Manually enabling a job:

dbms_scheduler.enable('DEMO_SHELL_JOB');
0
 

Author Comment

by:sanpradeep
ID: 35144987
Now i have enabled the job.. but my job is failing...
 select log_date
 ,      job_name
 ,      status
 from dba_scheduler_job_log
where  job_name = 'DEMO_SHELL_JOB';

15-MAR-11 11.37.12.559177 PM -07:00
DEMO_SHELL_JOB
FAILED

I have scheduled another job with zero arguments.. and this job executed successfully..
In the current scenario, am I passing the argument correctly... Does the argument I pass goes to the shell script as $1.

Also I executed the shell script directly in unix.. it got executed. So there is no problem with the script that I am trying to execute...
I doubt there is some problem with the argument I pass..
Please help...

0
 

Author Comment

by:sanpradeep
ID: 35146142
Thanks pkwan..

The issue was related to path settings... It is resolved now..
Thx for your help...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
selective queries 7 38
MULTIPLE DATE QUERY 15 91
capture vmstat info and insert it into an oracle table 31 38
Toad 12.10 Enterprise visual interface 4 22
Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question