Running an O/S script from DBMS_SCHEDULER



  • Have a need to run an O/S bash script from an Oracle 19.6 database.

    Here is my test case on my test database:

    I want it to write out to a file, but right now I can't even get the job to run.

    SQL> host cat test.sh
    source /home/oracle/.bashrc
    

    /bin/echo "TEST SCRIPT!" > test_script.out

    /bin/echo “Job ok!”;

    SQL> host /home/oracle/sql/test.sh
    “Job ok!”

    Result

      STATUS     ADDITIONAL_INFO
    ---------- -----------------------------------------------------
    FAILED     EXTERNAL_LOG_ID="job_293887_405260",
               ORA-27369: job of type EXECUTABLE failed with exit co
               de: No such file or directory
    

    HOWEVER, I've given it the whole path and creds with the secret password

    SQL> host ls /home/oracle/sql/test.sh
    /home/oracle/sql/test.sh
    

    program_type => 'EXTERNAL_SCRIPT',
    program_action => '/home/oracle/sql/test.sh',
    number_of_arguments => 0,
    enabled => TRUE,

    dbms_credential.create_credential(
    credential_name => 'ORACLE_CRED',
    username => 'oracle',

    DBMS_SCHEDULER.SET_ATTRIBUTE (
    name => 'TEST_EXECUTABLE',
    attribute => 'credential_name',
    value => 'ORACLE_CRED');

    What am I missing?



  • You're missing the OS access permissions for the oracle OS account.

    Make sure the OS user oracle can run it before trying to run it from DBMS_SCHEDULER.

    (Adjust account name according to the username => 'xxx' settings)


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2