Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: linux, crontab & oracle8

Re: linux, crontab & oracle8

From: Tim X <timx_at_spamto.devnul.com>
Date: 17 May 2003 14:21:07 +1000
Message-ID: <877k8qdwzw.fsf@tiger.rapttech.com.au>


>>>>> "Harald" == Harald Lapp <h.lapp_at_biering.de> writes:

 Harald> hello, i'm searching for a solution for the following  Harald> problem:

 Harald> i've written a script (in php), which fills an oracle
 Harald> database with data. the script will be run automatically by
 Harald> the cron-demon.

 Harald> when i run the script from commandline (e.g.  as user 'foo'
 Harald> everything works fine. but when i install the script as
 Harald> cronjob for this user, the script can't connect to the oracle
 Harald> database, it get's an error 'ORA-12154' which means afaik  Harald> 'TNS:could not resolve service name'
 Harald> i thought, that there might be some environment variables,
 Harald> that wheren't set for the specific user, so i've added the
 Harald> env command to the crontab entry and set the variables
 Harald> 'ORACLE_BASE', 'ORACLE_SID' and 'ORA_NLS33', but it still
 Harald> doesn't work.

 Harald> does somebody have an idea, what might be wrong?

 Harald> thanks, regards <-harald

I think your on the right track, but you have not provided enough info for a reliable answer.

You are quite right in suspecting environment variables may not be getting set. Normally a users environment is setup via the .profile or .login scripts. However, these scripts are only sourced for login shells. Crontab does not use a login shell, so none of your environment variables will be set.

How you set your environment variables for a crontab depends a bit on the flavor of UNIX your running. Often you can set them directly within the crontab itself. You say you have set some of the obvious ones like ORACLE_SID - ensoure you have set and exported all the ones needed and some of the less obvious ones like PATH.

Check the crontab man pages to see how your system recommends setting environment variables and remember it might be necessary to do an export/setenv on them so that they are inherited by sub-shells just in case your PHP script is running in a sub-shell (which is quite likely).

Tim

-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!
Received on Fri May 16 2003 - 23:21:07 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US