Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: I have a SQLPLUS question
You should never call sqlplus directly from the cron. What you really need
to do is put the sqlplus invocation inside a shell script and put the shell
script on the cron. Like this:
#!/bin/ksh
# Redirect output
exec >/tmp/myscript.log 2>&1
# Set ORACLE_SID and ORACLE_HOME
if [ -z "${ORACLE_SID}" ];then export ORACLE_SID=ORCL; export ORACLE_HOME=/oracle/app/oracle/product/7.3.4fi
# Invoke sqlplus
sqlplus -s scott/tiger @/mypath/myscript
if [ $? -ne 0 ];then
print -u2 "Fatal error from sqlplus"
exit 1;
fi
exit 0;
The reason you need to set ORACLE_SID and ORACLE_HOME is that these shell variables are probably set by your .profile and are therefore not set in the default environment that you'll get when you run a job from cron.
GreyWolf_69 wrote:
>
> what is the syntax for calling a sql file from a UNIX command line.
>
> I have a sql script that I want to run from cron, late at night. I
> can't seem to get the syntax correct, between user/password/sid and sql
> file name.
>
> Any help would be great.
>
> Thanks alot.
>
> Wolf
Received on Fri Oct 15 1999 - 06:44:53 CDT