tags:

views:

196

answers:

2

I made a management app imaginitively called update. The following work fine from the command line:

./manage.py update
/full/path/manage.py update

But when I have the following cron command:

00 */3 * * * /websites/bnc/manage.py update >/dev/null

It emails me this error:

Unknown command: 'update'

Type 'manage.py help' for usage.

It smells like a path issue but I can't see how because I can call it manually from wherever. Any idea what's going on here?

+2  A: 

The environment is likely not the same, so PYTHONPATH/PATH are not set. It might fail to find import django (or python/lib/site-packages).

Marcus Lindblom
How do I find the PYTHONPATH of my user? I tried `echo $PYTHONPATH` but it returned a blank line.
Oli
You can figure out where python/django is from python interactive prompt: >>> import django >>> print django.__file__ . That ought to give you a hint. Not sure on the details of cron and PYTHONPATH setup though. Perhaps write a small script that sets up env then runs manage.py update, instead of running it directly. You can test your script with the 'env' command, IIRC.
Marcus Lindblom
+1  A: 

I'm doing something similar. Try prefacing /websites/bnc/manage.py in your crontab with a PYTHONPATH=...

Jeff Bauer
How do I find the PYTHONPATH of my user? I tried echo $PYTHONPATH but it returned a blank line.
Oli