2016-09-04 72 views
0

我在使用django-archive獲取crontab執行站點備份時遇到了問題。通過crontab生產Django存檔

crontab文件:

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

錯誤:

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 $ 

python manage.py archive命令的偉大工程,如果我在gbsite/目錄是,但這裏有某種形式的路徑問題,我猜。這全部在生產服務器上運行。

回答

1

嘗試使用Python解釋器從你的virtualenv:

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

這是一個偉大的想法,雖然未發現蟒蛇上述路徑 – DeltaG

+0

@DeltaG沒有發現?這位翻譯的路徑是什麼?你能從你的CLI運行它並運行你想傳遞給cron的命令嗎? (我懷疑是許可問題)。 – vmonteco

+1

很明顯,你的精神環境的路徑將會不同! :) –