Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Saivishnu.

Asked: February 07, 2019 - 9:15 am UTC

Last updated: February 08, 2019 - 6:50 am UTC

Version: 12.2

Viewed 1000+ times

You Asked

Hi,
I want to schedule RMAN backup. So, i created the following job

begin
dbms_scheduler.create_job(
job_name => 'rman07_2',
job_type => 'EXECUTABLE',
job_action => 'C:\Windows\System32\cmd.exe',
number_of_arguments => 2,
auto_drop => TRUE
);
dbms_scheduler.set_job_argument_value('rman07_2',1,'/c');
dbms_scheduler.set_job_argument_value('rman07_2',2,'C:\Users\***\Desktop\rm.cmd');
dbms_scheduler.enable('rman07_2');
end;
/


thanks to many sources from online.

Though pl/sql is compiled successfully, trace is showing following error

ORA-27369: job of type EXECUTABLE failed with exit code: Incorrect function.

Either, there is something wrong with scheduler or my rm.cmd is causing some problem. Therefore, i am posting contends in rm.cmd.
D:\oracle\product\12.2.0\dbhome_1\bin\rman target sys/******* cmdfile=C:\Users\*******\Desktop\backup.txt

Contents of backup.txt is as follows
run 
{
shutdown immediate;
startup MOUNT;  
BACKUP DATABASE;  
STARTUP;
}

My rm.cmd can be run successfully.
Could you please help with this problem that i am facing currently?


and Connor said...

OK, can you start with this demo first

https://asktom.oracle.com/pls/apex/asktom.search?tag=dbms-scheduler-execute-bat-file

and make sure that this works on your server. If that fails, then something is wrong with the scheduler setup.

But if it is backup you want to run, we have native support in the scheduler for that as well, eg

declare
  l_rman   varchar2(32767);
begin
  l_rman := 'connect target /
run { 
  backup database;
}';

  dbms_scheduler.create_job(
    job_name        => 'my_job',
    job_type        => 'backup_script',
    job_action      => l_rman,
    credential_name => 'my_credentials',
    enabled         => true
  );
end;
/



Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Scheduler

All of the database utilities including the Scheduler are explained in the Utilities guide.