2011-08-02 55 views
0

我創建了自定義django-admin命令。我使用本教程Writing custom django-admin commands定製django-admin命令:使用模型和crontab的問題

例如,我的命令:

當我運行通過終端使用這個命令:

python manage.py build_task 

一切都OK了,我得到Destop 3個文件。

但是當我用crontab,

* * * * * /usr/bin/python /Users/macbook/builder/manage.py build_task 

我剛上車的桌面( 「Start.txt」)1個文件。顯然腳本停止了工作。

if tasks: 

請幫幫我。有什麼問題?

更新:在/ var /郵件/的MacBook:

File "/Users/macbook/workspace/acodebuilder/home/management/commands/build_apk.py",  
    line 26, in handle 
if tasks: 
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 113, in 
    __nonzero__ 
iter(self).next() 
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 107, in 
    _result_iter 
self._fill_cache() 
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 772, in 
    _fill_cache 
self._result_cache.append(self._iter.next()) 
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 273, in 
    iterator 
for row in compiler.results_iter(): 
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py", line 680, in 
    results_iter 
for rows in self.execute_sql(MULTI): 
File "/Library/Python/2.7/site-packages/django/db/models/sql/compiler.py", line 735, in 
    execute_sql 
cursor.execute(sql, params) 
File "/Library/Python/2.7/site-packages/django/db/backends/util.py", line 34, in 
    execute 
return self.cursor.execute(sql, params) 
File "/Library/Python/2.7/site-packages/django/db/backends/sqlite3/base.py", line 234, 
    in execute 
return Database.Cursor.execute(self, query, params) 

django.db.utils.DatabaseError: no such table: home_buildtask 

爲什麼 「沒有這樣的表」?

回答

0

這是由SQLite db引起的問題,我們必須使用MySQL或PGSQL!

1

通過運行mail命令,您應該能夠看到命令的錯誤輸出(如果有的話)。或者,您可以將&> ~/Desktop/django-command-error.log附加到crontab項中,並且cron作業的錯誤輸出將保存到桌面上的django-command-error.log