Google+ Followers

Pages

Wednesday, August 28, 2013

execute shell script USING DBMS_SCHEDULER

--- create shell scrip as below

[oracle@server1 ~]$ cat vmstat.sh

#!/bin/bash
/usr/bin/vmstat >> /home/oracle/x.txt


---create job , set arguments and enable

begin
 dbms_scheduler.create_job
(
job_name => 'My_job',
job_type => 'EXECUTABLE',
job_action => '/bin/bash',

  start_date =>sysdate ,
number_of_arguments => 1,
repeat_interval => 'FREQ=secondly; INTERVAL=5',
enabled => false,
comments => 'shell script test'
);

dbms_scheduler.set_job_argument_value(job_name=>'My_job', argument_position=>1, argument_value=>'/home/oracle/vmstat.sh');
dbms_scheduler.enable(name=>'My_job');
end;

--- DD VIEW


select * from dba_scheduler_job_run_details x where x.job_name='MY_JOB';