2011-08-02 7 views
0

사용자 정의 django-admin 명령을 작성했습니다. 내가 사용하는 단말기가이 명령을 실행할 때사용자 정의 django-admin 명령 : 사용 모델 및 crontab 문제

import os 
from home.models import BuildTask 

class Command(BaseCommand): 
    def handle(self, *args, **options): 

     tasks = BuildTask.objects.all() 

     os.system("touch /Users/macbook/Desktop/Start.txt") 

     if tasks: 
      os.system("touch /Users/macbook/Desktop/TasksExist.txt") 
     else: 
      os.system("touch /Users/macbook/Desktop/TasksNotExist.txt") 

     os.system("touch /Users/macbook/Desktop/End.txt") 

는 :

python manage.py build_task 

모든 것이 OK입니다, 내가 Destop에 3 개 개의 파일을 얻을 나는이 튜토리얼 예를 들어 Writing custom django-admin commands

, 내 명령을 사용합니다. 난 그냥 바탕 화면 ("Start.txt")에 1 개 파일을 가져

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

하지만 난 사용 crontab을

. 분명히 스크립트는 작업을 중단합니다.

if tasks: 

도와주세요. 뭐가 문제 야?

업데이트 :은/var/메일/맥북 : 왜 "그런 테이블"

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

명령을 실행하여 명령의 오류 출력 (있는 경우)을 볼 수 있어야합니다. 또는 &> ~/Desktop/django-command-error.log을 crontab 항목에 추가하면 cron 작업의 오류 출력이 바탕 화면의 django-command-error.log에 저장됩니다.

관련 문제