[Django]-Django "manage.py index" does not execute as a cron job

6đź‘Ť

âś…

Your error is probably because you don’t have your PYTHONPATH set properly, especially to include the path to the “notification” module. You also need to set the DJANGO_SETTINGS_MODULE path, if it isn’t already set in your environment.

Here’s a shell script I use to wrap my own django based cron task:

#!/bin/sh
DJANGO_SETTINGS_MODULE=mysettings
export DJANGO_SETTINGS_MODULE

PYTHONPATH=/path/to/python_libs:/path/to/my_django_apps
export PYTHONPATH

/path/to/python /path/to/my_django_script
👤ars

0đź‘Ť

As ars alluded to, cron runs with an entirely different set of environment variables than you do. The easiest way to fix that is to use a script similar to what he posted.

Leave a comment