0

我正在尝试让 crontab 任务在 webfaction 托管的 django 项目上工作。我根据与在不同网络派系服务器上工作的语句相同的语句对其进行建模:

*/2 * * * * (cd /home/mb52089/webapps/smartcarpools_prod/smartcarpools; /usr/local/bin/python2.7 manage.py send_msg >> /home/mb52089/webapps/smartcarpools_prod/arch_send_msg.log 2>&1)

收到以下错误:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/home/mb52089/lib/python2.7/django/core/management/__init__.py", line 459, in execute_manager
    utility.execute()
  File "/home/mb52089/lib/python2.7/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/mb52089/lib/python2.7/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/mb52089/lib/python2.7/django/core/management/__init__.py", line 70, in load_command_class
    return module.Command()
AttributeError: 'module' object has no attribute 'Command'

如果我尝试从命令行运行它,该命令也不起作用。但是,如果我运行 python2.7 manage.py shell,那确实有效,所以我开始使用 manage.py 了。

我已经在这个上旋转了一段时间,而 webfaction 并没有太大帮助。任何帮助是极大的赞赏。谢谢!

4

1 回答 1

0

我犯了一个菜鸟错误,完全遗漏了 django 命令任务的一些必要结构:

class Command(BaseCommand): 
help = 'Deletes expired legs, preferences and assignments' 
    def handle(self, *args, **options):
于 2012-04-24T22:34:45.910 回答