Crontab problem!

Hi All,

i added a sh script to crontab, it run but there is sqlplus expression that generate a spool file(gun.lst). this expression didnt run.

Summary,

1- my main script is topl.sh that i added it to Cron via "crontab -e" command
2- There is "sqlplus username/password@serverA @umt.sql" expression in topl.sh
3-umt.sql exists:
SET heading OFF
SET termout off
SET underline OFF
col offline_directory format a50
SET pagesize 0
SET verify OFF
SET echo off
SET linesize 50
SET feedback off
spool gun
select t.deger from tts.parametre t where t.id=30
;
spool off
exit;

4- All commands,expressions which are in topl.sh run, but "sqlplus username/password@serverA @umt.sql" expression didnt run so topl.sh script didnt generate gun.lst spool file.

by the way, when i run topl.sh manuel(without Cron), it is successfully.everything is ok.

i dont know why gun.lst spool file wasnt generated, when i add it on Cron.

Not: i added it to cron like that:
00 9 * * * /....../topl.sh

Thanx.

Hi,
have a look at the FAQ about cron.
The issues I see:
1) your environment is not set up: sqlplus is not found (PATH-variable), $ORACLE_HOME and $ORACLE_SID are not set.
2) I would use full pathnames when calling umt.sql and defining the outputfile gun.lst. Remember in cron your "current working directory" may not be what you expect...

Cero is correct. Your environment is not setup. The reason for this is that cron does NOT automatically source the profile. You need to source it in your script. Let's say my default shell is ksh. In my scripts I always source the profile....

#!/usr/bin/ksh

#
# Source the profle.
#
# Note there is a space between the dot "." and the tilde "~"
#
# The tilde is equivalent to $HOME
#
. ~/.profile

Hope this helps and good luck.

Hello,

in crontab (HP-UX) i use :

export USER=username; sh absolute_path_script

So the environment for the user is set properly.

Regards

hi bdittmar,

where will i write "export USER=myusername" sh myscript.sh?

must i write these in .profile file or in crontab or ...?

Thanx

Hello,

for example:

50 02 * * 5 export USER=jobs4c;sh /daten/bse/etc/rc.startjob FC100

Regards

Thank so much my friend, it is success and now everything is ok.