Solved

Invoke Shell script using dbms_scheduler

Posted on 2011-03-15
3
1,127 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle RAC 12c 8 72
Oracle Next Available Number 2 42
Distinct values from all columns in a table?? PL SQL 4 37
Oracle function to insert records? 15 42
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

772 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