More than likely, this problem is caused by the default shell environment variables setup by crontab. Cron supplies a default (bare) environment for every shell:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh
Here are a few solutions:
Here is a simple test to know exactly what variables are different, or even missing, in the crontab environment:
From the shell prompt, enter:
$ env > /tmp/myenv.log
Then set a cron job to do the same from the crontab.
$crontab -e
* * * * * env > /tmp/crontabenv.log
:wq
This line in the crontab will execute every minute, and store the environment variables in /tmp/crontabenv.log . diff both files to find the differences.
For more info about how to edit and use the crontab do: $man crontab
Thank You ! I experienced similar problem, searched for "crontab bash", and
your post showed straight away. It's because crontab uses sh as its shell,
instead of bash.