DeltaG DeltaG - 2 months ago 22
Python Question

Django archive via crontab in production

I'm having trouble getting crontab to execute a site backup, using django-archive.

crontab file:

0 5 * * * python ~/SBGBook/gbsite/manage.py archive


Error:

Traceback (most recent call last):
File "/home/jgates/SBGBook/gbsite/manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available $


The
python manage.py archive
command works great if I'm in the
gbsite/
directory, but there's some sort of path issue here, I'm guessing. This is all running in a venv on a production server.

Answer

Try to use the python interpreter from your virtualenv :

0 5 * * * /path/to/virtualenv/bin/python ~/SBGBook/gbsite/manage.py archive
Comments