Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







ORA-01012: job fails when placed in crontab

Expert Oracle Database Tips by Donald BurlesonFebruary 14, 2015


Question:  I have a job to refresh a materialized view and it runs great in SQL*Plus.  However, when I try to run the job from a UNIX crontab, the cron returns this error:

ORA-02068: following severe error from EAISPL1_TO_CLARITY
ORA-01012: not logged on  

How do I get an Oracle job to run from a cron?

Answer: There are serious limitations to scheduling jobs with UNIX/Linux crontab files, especially when the server is down when a shell script is set to execute, the job will be "missed".  If you used dbms_scheduler, it would ?remember? the missed jobs.     

Also, a crontab uses the privileges and environmental settings of the UNIX user that invokes the crontab . . .  

You start by using the oerr utility to display the text of the ORA-01012 error:

ORA-01012: not logged on  

Cause: A host language program issued an Oracle call, other than OLON or OLOGON, without being logged on to Oracle. This can occur when a user process attempts to access the database after the instance it is connected to terminates, forcing the process to disconnect.  

Action: Log on to Oracle, by calling OLON or OLOGON, before issuing any Oracle calls. When the instance has been restarted, retry the action

Here we see that the crontab invocation of the Oracle job fails because you are not using the same user ID that you did inside SQL*Plus.  

There are three solutions to the ORA-01012 error:

  1. signon within the job
  2. use external authentication
  3. remove the crontab and use dbms_scheduler

Let's examine these options for fixing a broken crontab:

  • Have the crontab submit a shell script that signs-on to Oracle as the same user ID you used in SQL*Plus:

    # First, we must set the environment . . . .
    export ORACLE_SID
    ORACLE_HOME=`cat /etc/oratab|grep ^$ORACLE_SID:|cut -f2 -d':'`
    export ORACLE_HOME
    export PATH

    $ORACLE_HOME/bin/sqlplus myuserid/mypass<<!
    spool myfile.txt
    select * from v\$database;

  • If you are in a secure, closed environment, you can use external authentication and have the cron use the UNIX user to get the privileges.

  • Abandon the crontab and schedule the job within Oracle using dbms_scheduler.

 For examples, see the great book ?Oracle Shell Scripting?. 

If you want pre-written and tested crontab scripts, get the Oracle script download.


Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.



Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster