Operating System - HP-UX
1838374 Members
3209 Online
110125 Solutions
New Discussion

cron failing I need help.

 
SOLVED
Go to solution
Boniface Chiwenda
Occasional Contributor

cron failing I need help.

Hi everyone
I set up a cron to start an sql command under a different user name other than root.
the cron looks like this.
07 16 * * * $TFADMIN /home/asy/sqlplus snapadmin/snapadmin @crontest
and this is the error Iam getting
Message file sp1.msb not found
Error 6 initializing SQL*Plus
What could be the problem.

Regards
Bonnie.
4 REPLIES 4
David Child_1
Honored Contributor

Re: cron failing I need help.

Any reason you just don't run this cron job as 'crontest' instead of root?

I've never tried doing it the way you have listed. Normally I would do:
07 16 * * * su - crontest -c ".../sqlplus..."

David
A. Clay Stephenson
Acclaimed Contributor

Re: cron failing I need help.

Cron has an intentionally sparse environment. It doesn't have a clue about $TFADMIN whether or not you have defined it in the user's .profile or /etc/profile.

You really have to invoke your script (which is typically a wrapper script) with a fully qualified pathname and then the script itself should explicitly set and export any needed environment variables before actually spawning the real script.
If it ain't broke, I can fix that.
Boniface Chiwenda
Occasional Contributor

Re: cron failing I need help.

Thanks for your help.
Let me give it another try.

Regards
Bonnie
R. Allan Hicks
Trusted Contributor
Solution

Re: cron failing I need help.

Unless you source Oracle's environment, you will not be able to run sqlplus. You may want to either

Take your cron command and put it into a script;

#!/bin/ksh
# get oracle's environment
. /home/oracle/.ora_defaults

$TFADMIN/home/asy/sqlplus snapadmin/snapadmin @crontest

------ or ------------

my_script contains

#!/bin/ksh
# get oracle's environment

$TFADMIN/home/asy/sqlplus snapadmin/snapadmin @crontest

cron table has su - oracle -c my_script

assuming $TFADMIN is defined somewhere
"Only he who attempts the absurd is capable of achieving the impossible