RE: Why isn't my script running?

Well, there you go, sqlplus not found.

That means PATH was not modified to contain $ORACLE_HOME/bin.

Most likely cause is that you didn't run '. oraenv'.

A quick look at your script, and sure enough, you set:
export ORACLE_SID=SPIPRD
export ORAENV_ASK=NO

But you neglect to actually call '. oraenv' to setup the correct environment.

Try adding:
. oraenv

immediately following:
export ORAENV_ASK=NO

in your script.


That ought to do it,

-Mark
-----Original Message-----
From: Eugene Pipko [mailto:eugene.pipko@xxxxxxxxxxxx] 
Sent: Wednesday, February 25, 2009 1:13 PM
To: Bobak, Mark; 'Mercadante, Thomas F (LABOR)'
Cc: 'oracle-l@xxxxxxxxxxxxx'
Subject: RE: Why isn't my script running?

It is there:

[oraprd@findb01kt ~]$ cd /home/oraprd/scripts/logs
[oraprd@findb01kt logs]$ ls -l
total 4
-rw-r--r--  1 oraprd dba 199 Feb 25 09:40 spi_schema_stats.log

[oraprd@findb01kt logs]$ cat spi_schema_stats.log
/bin/sh: /home/oraprd/scripts/spi_schema_stats.sh: Permission denied
/home/oraprd/scripts/spi_schema_stats.sh[18]: sqlplus: not found
/home/oraprd/scripts/spi_schema_stats.sh[18]: sqlplus: not found
[oraprd@findb01kt logs]$


Eugene Pipko
  Please consider the environment before printing this e-mail.


-----Original Message-----
From: Bobak, Mark [mailto:Mark.Bobak@xxxxxxxxxxxx] 
Sent: Wednesday, February 25, 2009 10:07 AM
To: Eugene Pipko; 'Mercadante, Thomas F (LABOR)'
Cc: 'oracle-l@xxxxxxxxxxxxx'
Subject: RE: Why isn't my script running?

Does /home/oraprd/scripts/logs/spi_schema_stats.log exist?

Is there anything written to it?

Can you post the contents?

-Mark

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of Eugene Pipko
Sent: Wednesday, February 25, 2009 12:55 PM
To: 'Mercadante, Thomas F (LABOR)'
Cc: 'oracle-l@xxxxxxxxxxxxx'
Subject: RE: Why isn't my script running?

Tom,
You were right: it was missing +x, so after chmod +x test_schema_stats.sh I 
have the following:

[oraprd@findb01kt scripts]$ cd /home/oraprd/scripts/
[oraprd@findb01kt scripts]$ ls -l
total 12
drwxr-xr-x  2 oraprd dba 4096 Feb 11 08:37 logs
-rwxr-xr-x  1 oraprd dba  516 Feb 25 08:59 test_schema_stats.sh

Here is the script:

#!/bin/ksh
USER=SYSTEM
PASSWORD=test
export ORACLE_SID=SPIPRD
export ORAENV_ASK=NO
sqlplus -s $USER/$PASSWORD <<EOF
set feed off
set head off
set pagesize 0
exec dbms_stats.gather_schema_stats('TEST',ESTIMATE_PERCENT=>30,CASCADE=>TRUE)
exit;
EOF

Here is the cron:

40 9 * * * /home/oraprd/scripts/spi_schema_stats.sh  >> 
/home/oraprd/scripts/logs/spi_schema_stats.log 2>&1

Still won't fire from cron, but runs as $sh test_schema_stats.sh


Eugene Pipko
  Please consider the environment before printing this e-mail.


-----Original Message-----
From: Mercadante, Thomas F (LABOR) [mailto:Thomas.Mercadante@xxxxxxxxxxxxxxxxx] 
Sent: Wednesday, February 25, 2009 8:48 AM
To: Eugene Pipko
Cc: oracle-l@xxxxxxxxxxxxx
Subject: RE: Why isn't my script running?

Eugene,

Your cron says:
00 01 * * 7 /home/oraprd/scripts/test_schema_stats.sh

You run it from the command line as:
$sh test_schema_stats.sh

There is a difference there.  Have you set the executable bit on the file?

chmod +x test_schema_stats.sh

And you are absolutely sure that it exists in the named directory.

One other option:  Your cron entry could be:

00 01 * * 7 sh /home/oraprd/scripts/test_schema_stats.sh

I do not prefer to run it this way as I use korn shell for all my scripting.

Hope this helps.

Tom

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of Eugene Pipko
Sent: Wednesday, February 25, 2009 11:09 AM
To: 'z b'
Cc: 'oracle-l@xxxxxxxxxxxxx'
Subject: RE: Why isn't my script running?

Thanks everyone for your replies.

Yes, I could use dbms_job, but I am trying to learn to use cron.

I've implemented all the suggestions, but ... the script still wouldn't fire 
from cron.
It runs just fine if I do: $sh test_schema_stats.sh.
I will spend some more time trying to figure it out.

Eugene Pipko
  Please consider the environment before printing this e-mail.

-----Original Message-----
From: z b [mailto:zimsbait@xxxxxxxxx] 
Sent: Tuesday, February 24, 2009 6:32 PM
To: Eugene Pipko
Cc: oracle-l@xxxxxxxxxxxxx
Subject: Re: Why isn't my script running?

If this is the actual script, why not use dbms_job (< 10g) or
dbms_scheduler (> 10g)?

On Tue, Feb 24, 2009 at 1:15 PM, Eugene Pipko <eugene.pipko@xxxxxxxxxxxx> wrote:
> Hi all,
>
> I am new to shell. I need to calculate stats for a schema using cron (oracle
> linux 4).
>
> For some reason my script is not running.
>
> --------------------------------------
>
> #!/bin/ksh
>
> USER=SYSTEM
>
> PASSWORD=pwd
>
> sqlplus -s $USER/$PASSWORD <<EOF
>
> set feed off
>
> set head off
>
> set pagesize 0
>
> exec
> dbms_stats.gather_schema_stats('TEST',ESTIMATE_PERCENT=>30,CASCADE=>TRUE);
>
> /
>
> exit 0;
>
> EOF
>
> -------------------
>
>
>
> Then in Linux:
>
> 00 01 * * 7 /home/oraprd/scripts/test_schema_stats.sh 1&2 >>
> /home/oraprd/scripts/logs/test_schema_stats.log
>
>
>
> Thanks,
>
> Eugene Pipko
>
> P  Please consider the environment before printing this e-mail.
>
>
i0zX+n{+i^
m����
�祊�l��?���j
�����

Other related posts: