I have a python script that connects to an external host, fetches some data, and populates a Django database with the data. The python script that populates the database uses these lines to setup the django environment:
path = os.path.normpath(os.path.join(os.getcwd(), '..'))
sys.path.append(path)
from django.core.management import setup_environ
import settings
setup_environ(settings)
Then I have a shell script that actually runs the python script:
export PYTHONPATH=$PYTHONPATH:/home/django/project_dir/
cd ~/project_dir/scripts/
~/virtualenv/bin/python my_script.py
And then my cron config, which is placed in /etc/cron.d/
0 1 * * * django ~/project_dir/scripts/my_script.sh > /var/log/django_cron.log
Note that the django project has it's own user and virtual environment.
The shell script runs fine when I am logged in as the django user. But the cron won't run! I get no errors in the log file. I'm sure it's something very simple, but I just don't see it...