Schedule shell or batch script in dbms_scheduler package

Example of scheduling the Shell or batch script in DBMS Schedule.

Create a Credential Store in Oracle Database with existing OS User.

BEGIN
dbms_credential.create_credential (
CREDENTIAL_NAME => 'ORACLEUSER',
USERNAME => 'oracle',
PASSWORD => 'oracle@123',
DATABASE_ROLE => NULL,
WINDOWS_DOMAIN => NULL,
COMMENTS => 'Oracle OS User',
ENABLED => true
);
END;
/

Use that Credential in DBMS Scheduler job having writes to execute the Shell Script. Create DBMS Scheduler job which executing the shell script

-- Create the job:
BEGIN
dbms_scheduler.create_job(
job_name=>'JOB1',
job_type=>'external_script',
job_action=>'/u01/app/oracle/test.sh',
enabled=>true,
START_DATE=>sysdate,
REPEAT_INTERVAL =>'FREQ=MINUTELY; byminute=1',
auto_drop=>false,
credential_name=>'ORACLEOSUSER');
END;
/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.