Jorge Flores
Jorge Flores

Reputation: 117

How to execute bash/shell script in Linux from an Oracle DBMS_Scheduler?

I have a Linux Oracle Server. The database is generating CSV files with a custom stored procedure, now at the end of this procedure. I want to execute a bash/shell script in linux to push this files to Amazon S3 Bucket.

I am getting errors trying to schedule the process in oracle:

EXTERNAL_LOG_ID="job_2369137_852690", ORA-27369: job of type EXECUTABLE failed with exit code: Argument list too long

Using DBM_SCHEDULER to create a JOB type Sript, External

#!/bin/bash
echo hello world

DBMS_SCHEDULER.CREATE_JOB (
job_name => '"ODSMGR"."TEST_JOB"',
job_type => 'EXTERNAL_SCRIPT',
job_action => '#!/bin/bash
echo hello world',
number_of_arguments => 0,
start_date => NULL,
repeat_interval => NULL,
end_date => NULL,
enabled => FALSE,
auto_drop => FALSE,
comments => '');

Upvotes: 0

Views: 5675

Answers (1)

Kaushik Nayak
Kaushik Nayak

Reputation: 31676

The DBMS_SCHEDULER.CREATE_JOB you are using has incorrect arguments. You should preferably follow these standard steps for running a program.

First create a program with appropriate name and define what to run. In the below example I'm running a bash command directly, You may put them into a separate shell script with relevant permissions and add its name under program_action

BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM (
 program_name=> 'COPY_PROGRAM',
 program_type=> 'EXECUTABLE',
 program_action  => '/bin/bash -c "echo hello world"',
 enabled=> TRUE,
 comments=> 'Push files to Amazon S3 Bucket.'
);
END;
/

Then, create the job using that program.

BEGIN
DBMS_SCHEDULER.CREATE_JOB (
   job_name     => 'TEST_JOB',
   program_name => 'COPY_PROGRAM',
   start_date => NULL,
   repeat_interval => NULL,
   end_date => NULL,
   enabled => FALSE,
   auto_drop => FALSE,
   comments => '');
END;
/

Refer this link for more details.

Upvotes: 1

Related Questions