Shell Script gives error when run through cron job.

Hi,

The following shell script runs without any problem when executed manulally.

USED=$(df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1)
if [ ${USED} -gt 90 ]
then
  find /arch/AUBUAT/ -type f -mtime +0 | xargs rm
  find /arch/AUBMIG/ -type f -mtime +0 | xargs rm
fi
```[/b]


But the same gives below error when called from a cron job:
/backup/arch_test.sh: syntax error at line 1: \`USED=$' unexpected

We are running following version:
```text
bash-3.00$ uname -a
SunOS uaeaubdbdr01.aub.af 5.10 Generic_141444-09 sun4u sparc SUNW,SPARC-Enterprise

Kindly assist.

Thanks

please read our fine FAQ:

Hi,

Thx for the update. However, I tried different options but still the problem persists.

Thanks

try backticks instead of $()

USED=`df -h /arch | tail -1 | awk '{print $5}' | cut -d '%' -f 1`

or define a posix conform shell in your script like "#!/bin/ksh".

have you tried, in crontab:

* * * * * /usr/bin/bash -c your_script

Check the shell in which you r running the scripts

try cut -d% -f1