Link to home
Create AccountLog in
Unix OS

Unix OS

--

Questions

--

Followers

Top Experts

Avatar of mmemon
mmemon

Cron Job and SQL Loader
Good Morning,

This is my first time creating a cron job so please forgive my ignorance...
I would like to know the basic steps in completing this. I am receiving errors and not sure what I am doing wrong.

I am using a tool called Webmin. There is an interface that allows you to create a scheduled cron job.

My script needs to launch sqlldr to import data into an oracle table..

In the webmin tool, in the command box I have this line of code:

/u01/app/oracle/product/9.0.1/cron_scripts/billing_data_load

Inside the billing_data_load, I have this code:

#! /bin/sh
ORACLE_SID=NAME
export ORACLE_SID
cd $ORACLE_HOME
./oraprofile

/u01/app/oracle/product/9.0.1/bin/sqlldr prod_dba/alf@NAME silent=header feedback errors discards partitions control=/u01/app/oracle/product/9.0.1/unixTest.ctl log=/u01/app/oracle/product/9.0.1/unixTest.log data=/u01/app/oracle/product/9.0.1/SPACE_ALL_T.txt

I read somewhere that I needed to put the below code in a file called oraprofile:

#!/bin/sh
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/9.0.1
ORACLE_SID=NAME
PATH=$PATH:$ORACLE_HOME/bin:/usr/local/bin:$ORACLE_HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH


Can anyone tell me if I am missing something or if I am on the right track.. The first error message I got had something to do with Message Not Found 2100....

Thank you
Michele


Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of liddlerliddler🇮🇪

what is in your crontab?
ie.
type crontab -l

what is the exact message you get if you run the command
i.e run
/u01/app/oracle/product/9.0.1/cron_scripts/billing_data_load
do you get the error now, or is it only when you run it from cron.

what is the exact error?
Is there anything in /u01/app/oracle/product/9.0.1/unixTest.log ?

Avatar of mmemonmmemon

ASKER

Hi

Thanks for your response...

1) When I type crontab -l I get this:
40 15 * * 1-5 /u01/app/oracle/product/9.0.1/cron_scripts/billing_data_load >/dev/null

2) When I sign in as root and run u01/app/oracle/product/9.0.1/cron_scripts/billing_data_load, it works. So I only get the error from cron

3) The exact error is:SQL*Loader-704: Internal error: ulconnect: OCIInitialize [1804]

But I wasn't sure if this was a result of me not setting up the cron successfully. According to this error, I should call oracle support services but I guess I wanted to make sure that I set up everything correctly first


I can't quite understand why you're redirecting the output of your cron job to /dev/null (> /dev/null), but perhaps there's a very good reason? In addition, be aware that cron doesn't have any environment of it's own (except a very minimal one), so you need to include within your script any PATH variables etc which would be available to the user who could sucessfully run the job from the command line. Hope this helps.

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


Avatar of liddlerliddler🇮🇪

Do your sqlldr work?  If it does and you just don't want to see the error append 2>&1 onto your cronjob.
i.e.
40 15 * * 1-5 /u01/app/oracle/product/9.0.1/cron_scripts/billing_data_load >/dev/null 2>&1
This redirects standard error to the same place as standard out  - /dev/null, which means ignore it.
If it is not working it will be to do with a variable / path not set in the cron shell as kencunningham as said.  It might be worth removing the ./oraprofile line and replacing it with the code:
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/9.0.1
ORACLE_SID=NAME
PATH=$PATH:$ORACLE_HOME/bin:/usr/local/bin:$ORACLE_HOME/bin

export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH

One way to make sure you get the oracle environment is to put the job into roots cron with the entry something like:
su - oracle /u01/app/oracle/product/9.0.1/cron_scripts/billing_data_load

The "su -" will read the environment and make it available for the process.

ASKER CERTIFIED SOLUTION
Avatar of MiniMaxXPCMiniMaxXPC

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of mmemonmmemon

ASKER

Hi MiniMaxXPC,

I first have to say thank you so much for your detailed response. Not only was I able to resolve my issue but I now have a full understanding of how things work ,what to look for in debugging an issue and how to set things up.
I wasn't even aware of the oraenv file until I read your response.
I appreciated your mini lesson and are very grateful for the time you taken to explain it to me..

Also, many thanks to everyone for responding to my question....

Michele



Free T-shirt

Get a FREE t-shirt when you ask your first question.

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.

Unix OS

Unix OS

--

Questions

--

Followers

Top Experts

Unix is a multitasking, multi-user computer operating system originally developed in 1969 at Bell Labs. Today, it is a modern OS with many commercial flavors and licensees, including FreeBSD, Hewlett-Packard’s UX, IBM AIX and Apple Mac OS-X. Apart from its command-line interface, most UNIX variations support the standardized X Window System for GUIs, with the exception of the Mac OS, which uses a proprietary system.