Can run script Manually, but not through Cron?

Hi all,

I have a main script (called OracleCleanup) that runs some sql queries. that runs off a wrapper script which contains the sources for the login information and and JOB_HOME (the script is below). When I schedule this job in the cron the log says that it cannot open my list file, which is located in somefolder. If i run this script manually by simply invoking it, it runs without any issues. Any ideas?

#!/bin/ksh

# Source appropriate login information
. $HOME/somefolder/login_Cleanup.ksh

# Set the JOB_HOME (ie. where the lists of tables to archive are held)
export JOB_HOME=/home/oracle/somefolder

# Run the job.
$HOME/somefolder/OracleCleanup.ksh

# Rename logfile
mv $HOME/somefolder/log/OracleCleanup.log $HOME/chris/log/OracleCleanup.`date +%m_%d_
%Y`.log

Hello Madhatter,
I would suggest that you change the shell to the native shell for (most) systems, i.e. /bin/sh. The cron function may use this shell instead of the "K - shell" I would suggest starting there.

On AIX (and HP-ux IIRC) the default shell is ksh, so that doesn't need to be the problem.

your cronjobs might be executed under a different user, so check the rights of ..../somedir to make sure it is accessible from within your cronjob.

bakunin

This has been addressed in a FAQ entry.

either change
. $HOME/somefolder/login_Cleanup.ksh
to
. /wherever/home/is/somefolder/login_Cleanup.ksh
(and do similar things for other $HOME occurrances)

or

export HOME=/wherever/home/is

before the first use of $HOME

Cheers
ZB

thanks for all the suggestions everyone! turns out that the list file wasn't fully qualified in the main script. it wasn't pathed at all, so that's why it only worked manually when i was in the current folder. I don't know how i didn't see that!