Cron job running problem

Hi Guys,

I am trying to run a script through contab. The script can only be executed once user logs in as su - oracle. I have tested the script other then cronjob and it executes successfully, more over the paths used in the script are absolute paths.

Crontab entries are as as below.

15,30,45,59 * * * * su -oracle -c /var/opt/log/my.sh

Shell is as below, Shell interacts with the Oracle DB and extracts the required data.

root@ServerA[/var/opt/log]# cat /var/opt/log/db_analy.sh
#!/usr/bin/bash

sqlplus my_usr/my_passwd@ServerA @/var/opt/log/db.sql
root@ServerA[/var/opt/log]# cat db.sql
set HEA OFF
set heads off
set pagesize 0
SPOOL /var/opt/log/db_analyze.log
SELECT Count(*) From T1 WHERE $state = 'O'; 
SPOOL OFF
exit

If I execute this /var/opt/log/db_analy.sh --- it is executed sucessfully but there is no output wen i added it in conjob.

Any sugesstion will be appriciated.
Thx in advance,
BR//Asteroid

Failing cron jobs almost always have problems with environment variables, i.e., ORACLE_HOME, TWO_TASK....

to debug your problem:

15,30,45,59 * * * * su -oracle -c /var/opt/log/my.sh 2&>1 > /tmp/my.log

edit your script and add this at the top, right under #!/usr/bin/bash

set 

Which OS is it? Is it the crontab entry of root user? How do you exactly call that script when you run it manually?
This is a plain guess, but maybe there should be a whitespace between the minus sign and oracle :confused:

Thx guys, The problem has been resolved by setting environment variables.