Search code examples
unixshunzip

cron job failing at unzip of files


I have a shell script that I can run successfully from the command line.

However, when I try to run the same script inside a cron job, it runs successfully up to a portion where unzipping of files occurs and then fails at the unzip portion.

The echo of "UNZIP FILES" occurs and then the process fails.

Any ideas why I'm able to run the script successfully from the command line but not as a cron and why it might be failing at the unzip portion?

Here's the unzip portion of the script:

# Unzip the zipped files that were brought down
echo "\n*** UNZIP FILES ***"
cd $FILES_DIR
for z in *.zip; do unzip $z; done

Solution

  • The $PATH was different in crontab as opposed to the command line.

    I updated the $PATH in crontab to be the same as when I launch the command line and then was able to execute the crontab no problem.

    Thanks Zsolt Botykai for the good questions as they led me to the answer.