Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Invoke Shell script using dbms_scheduler

Posted on 2011-03-15
3
Medium Priority
?
1,266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 1000 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

705 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