ORA-27369: Job of Type EXECUTABLE Failed With Exit Code
ORA-27369: Job of Type EXECUTABLE Failed With Exit Code
Section titled “ORA-27369: Job of Type EXECUTABLE Failed With Exit Code”Error Overview
Section titled “Error Overview”Error Text: ORA-27369: job of type EXECUTABLE failed with exit code: NNN
ORA-27369 occurs when a DBMS_SCHEDULER job of type EXECUTABLE (running an external OS command or script) returns a non-zero exit code. The error message includes the exit code and a description, allowing the DBA to identify whether the script failed, was killed, or hit a permission issue.
Common Exit Code Meanings
Section titled “Common Exit Code Meanings”| Exit Code | Meaning |
|---|---|
| 1 | General script error |
| 2 | Misuse of shell builtin |
| 126 | Command found but not executable |
| 127 | Command not found |
| 128+N | Killed by signal N (e.g., 137 = SIGKILL) |
| 130 | Script terminated by Ctrl+C (SIGINT) |
| 137 | Killed by SIGKILL (often OOM) |
| 139 | Segmentation fault |
| 255 | Exit status out of range |
Common Causes
Section titled “Common Causes”Script Logic Errors
Section titled “Script Logic Errors”- Script itself returns non-zero
- Required input file missing
- Application-specific failure
- Database connection from script failed
Permission and Path Issues
Section titled “Permission and Path Issues”- Script not executable
oracleuser (or job credential) lacks permissions- Required binary not in PATH
- File ownership mismatch
Environment Problems
Section titled “Environment Problems”ORACLE_HOMEnot set in scheduler context- Library path missing
- Locale/timezone differences
- Environment variables not propagated
Credential Issues (12c+)
Section titled “Credential Issues (12c+)”- Required credential not configured
- Credential expired
- OS user not authorized
extjobconfiguration missing (older versions)
Resource Limits
Section titled “Resource Limits”- Memory limit triggered SIGKILL (exit 137)
- Disk full mid-execution
- Network unavailable for remote commands
Diagnostic Steps
Section titled “Diagnostic Steps”Check Job Status and Output
Section titled “Check Job Status and Output”-- Last run detailsSELECT job_name, status, error#, additional_info, run_duration, outputFROM dba_scheduler_job_run_detailsWHERE job_name = 'MY_EXTERNAL_JOB'ORDER BY actual_start_date DESCFETCH FIRST 5 ROWS ONLY;
-- Currently running and recentSELECT job_name, state, last_start_date, last_run_duration, last_executions, failuresFROM dba_scheduler_jobsWHERE job_name = 'MY_EXTERNAL_JOB';Inspect Job Definition
Section titled “Inspect Job Definition”-- Show job action and credentialSELECT job_name, job_type, job_action, credential_owner, credential_name, destinationFROM dba_scheduler_jobsWHERE job_name = 'MY_EXTERNAL_JOB';
-- For jobs using Job ClassSELECT job_class_name, resource_consumer_group, service, logging_levelFROM dba_scheduler_job_classesWHERE job_class_name IN ( SELECT job_class FROM dba_scheduler_jobs WHERE job_name = 'MY_EXTERNAL_JOB');Test Script Manually
Section titled “Test Script Manually”# Run as oracle user (or job credential user)sudo -u oracle /path/to/script.shecho "Exit: $?"
# Test with full PATHsudo -u oracle bash -c 'PATH=/usr/local/bin:/usr/bin /path/to/script.sh'
# Check executablels -la /path/to/script.shfile /path/to/script.shInspect Job Log Output
Section titled “Inspect Job Log Output”-- Output captured by schedulerSELECT log_id, job_name, log_date, status, additional_info, run_durationFROM dba_scheduler_job_run_detailsWHERE job_name = 'MY_EXTERNAL_JOB'AND log_date > SYSDATE - 1ORDER BY log_date DESC;Resolution Steps
Section titled “Resolution Steps”1. Decode Exit Code
Section titled “1. Decode Exit Code”-- Get specific exit codeSELECT job_name, error#, additional_infoFROM dba_scheduler_job_run_detailsWHERE job_name = 'MY_EXTERNAL_JOB'AND status = 'FAILED'ORDER BY log_date DESCFETCH FIRST 1 ROW ONLY;Map exit code to common cause table above.
2. Fix Script Permissions
Section titled “2. Fix Script Permissions”# Make executablechmod 755 /path/to/script.sh
# Set correct ownershipchown oracle:oinstall /path/to/script.sh
# For files accessed by scriptchmod 644 /path/to/data/input.csvchown oracle:oinstall /path/to/data/input.csv3. Set Up Credential (12c+)
Section titled “3. Set Up Credential (12c+)”-- Create credential for OS userBEGIN DBMS_CREDENTIAL.CREATE_CREDENTIAL( credential_name => 'OS_ORACLE_CRED', username => 'oracle', password => 'os_password' );END;/
-- Assign to jobBEGIN DBMS_SCHEDULER.SET_ATTRIBUTE( name => 'MY_EXTERNAL_JOB', attribute => 'credential_name', value => 'OS_ORACLE_CRED' );END;/
-- VerifySELECT job_name, credential_owner, credential_nameFROM dba_scheduler_jobsWHERE job_name = 'MY_EXTERNAL_JOB';4. Add Environment Setup to Script
Section titled “4. Add Environment Setup to Script”#!/bin/bash# Always source environment in script. /etc/profile. /home/oracle/.bash_profile
export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1export ORACLE_SID=PRODexport PATH=$ORACLE_HOME/bin:$PATHexport LD_LIBRARY_PATH=$ORACLE_HOME/lib
# Now run actual logicsqlplus -s /nolog <<EOFCONNECT / AS SYSDBAEXEC my_procedure;EXITEOF5. Configure External Job Settings (Older Versions)
Section titled “5. Configure External Job Settings (Older Versions)”For Oracle 11g, ensure extjobo/extjob is configured:
# As root, configure extjobcd $ORACLE_HOME/rdbms/admin./externaljob.ora.sample > $ORACLE_HOME/rdbms/admin/externaljob.ora
# Set in $ORACLE_HOME/rdbms/admin/externaljob.orarun_user = oraclerun_group = oinstall
# Set permissionschmod 640 $ORACLE_HOME/rdbms/admin/externaljob.orachmod 6750 $ORACLE_HOME/bin/extjobochown root:oinstall $ORACLE_HOME/bin/extjobo6. Increase Resource Limits
Section titled “6. Increase Resource Limits”# If exit code 137 (SIGKILL, often OOM)# Increase memory available to oracle useroracle soft memlock 16777216oracle hard memlock 16777216-- Or restrict job concurrencyBEGIN DBMS_SCHEDULER.SET_ATTRIBUTE( name => 'MY_JOB_CLASS', attribute => 'resource_consumer_group', value => 'BATCH_GROUP' );END;/7. Add Error Handling to Script
Section titled “7. Add Error Handling to Script”#!/bin/bashset -euo pipefail # exit on error, unset var, pipe fail
LOG=/tmp/myjob_$(date +%Y%m%d_%H%M%S).logexec > "$LOG" 2>&1
trap 'echo "Error at line $LINENO with exit $?"; exit 1' ERR
# Your logic hereecho "Starting job at $(date)"# ...
echo "Completed successfully"exit 0Common Scenarios
Section titled “Common Scenarios”Scenario 1: Script Not Found
Section titled “Scenario 1: Script Not Found”ORA-27369: job of type EXECUTABLE failed with exit code: 127 (Command not found)Fix: Use absolute path in job_action. Verify script exists at that path for oracle user.
Scenario 2: Permission Denied
Section titled “Scenario 2: Permission Denied”ORA-27369: job of type EXECUTABLE failed with exit code: 126Fix: chmod +x script.sh, verify ownership, check directory traversal permissions.
Scenario 3: Out of Memory
Section titled “Scenario 3: Out of Memory”ORA-27369: job of type EXECUTABLE failed with exit code: 137Fix: Script killed by OOM. Reduce memory usage or schedule outside peak hours.
Scenario 4: SQL*Plus in Script Fails
Section titled “Scenario 4: SQL*Plus in Script Fails”ORA-27369: job of type EXECUTABLE failed with exit code: 1Fix: Add set echo on; whenever sqlerror exit failure; to capture SQL errors. Source Oracle environment in script.
Sample Output
Section titled “Sample Output”SQL> SELECT job_name, status, additional_info 2 FROM dba_scheduler_job_run_details 3 WHERE job_name = 'BACKUP_JOB' 4 ORDER BY log_date DESC FETCH FIRST 1 ROW ONLY;
JOB_NAME STATUS ADDITIONAL_INFO------------- --------- ------------------------------------------BACKUP_JOB FAILED EXTERNAL_LOG_ID="job_12345_678", ORA-27369: job of type EXECUTABLE failed with exit code: 127
SQL> SELECT job_action FROM dba_scheduler_jobs 2 WHERE job_name = 'BACKUP_JOB';
JOB_ACTION--------------------------------------------------------------/u01/scripts/backup.sh
# Test manually[oracle@host]$ /u01/scripts/backup.sh-bash: /u01/scripts/backup.sh: No such file or directory
# Path was wrong; fix itSQL> BEGIN 2 DBMS_SCHEDULER.SET_ATTRIBUTE( 3 name => 'BACKUP_JOB', 4 attribute => 'job_action', 5 value => '/u01/app/scripts/backup.sh' 6 ); 7 END; 8 /Prevention Strategies
Section titled “Prevention Strategies”Always Use Absolute Paths
Section titled “Always Use Absolute Paths”-- Goodjob_action => '/u01/app/scripts/etl.sh'
-- Bad - relies on PATHjob_action => 'etl.sh'Source Environment in Scripts
Section titled “Source Environment in Scripts”#!/bin/bash# Always start with environment setup[ -f /etc/profile ] && . /etc/profile[ -f $HOME/.bash_profile ] && . $HOME/.bash_profile
export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1export ORACLE_SID=PRODexport PATH=$ORACLE_HOME/bin:/usr/local/bin:$PATHCapture Output and Exit Codes
Section titled “Capture Output and Exit Codes”-- Configure job to log outputBEGIN DBMS_SCHEDULER.SET_ATTRIBUTE( name => 'MY_JOB', attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_FULL );END;/Test Job Manually First
Section titled “Test Job Manually First”# Always run script as scheduler willsudo -u oracle bash -c 'export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1export PATH=$ORACLE_HOME/bin:/usr/bin/u01/scripts/myjob.shecho "Exit: $?"'Monitoring
Section titled “Monitoring”-- Daily failed job reportSELECT job_name, COUNT(*) AS failures, MAX(log_date) AS last_failureFROM dba_scheduler_job_run_detailsWHERE status = 'FAILED'AND log_date > SYSDATE - 1GROUP BY job_nameORDER BY failures DESC;-- Email alert on failureBEGIN DBMS_SCHEDULER.SET_ATTRIBUTE( name => 'MY_JOB', attribute => 'raise_events', value => DBMS_SCHEDULER.JOB_FAILED );END;/Related Errors
Section titled “Related Errors”- ORA-27370: Job slave failed to launch
- ORA-27371: Invalid scheduler credentials
- ORA-27300: OS system dependent operation failed
- ORA-27302: Failure occurred at skgpspawn
- ORA-12011: Execution of jobs failed
Troubleshooting Checklist
Section titled “Troubleshooting Checklist”- Capture exit code from
dba_scheduler_job_run_details - Decode exit code (1=script error, 127=not found, 137=killed)
- Verify script path is absolute and correct
- Check script is executable by job credential user
- Validate environment setup in script
- Configure credential for 12c+ external jobs
- Enable full logging on job class
- Test script manually as oracle user