Search code examples
djangocronwebfaction

django cron error on webfaction


I am trying to get a crontab task to work on a django project hosted by webfaction. I modeled it after a statement identical to one that works on a different webfaction server:

*/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)

Getting the following error:

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'

the command also does not work if I try to run it from the command line. However, if I run python2.7 manage.py shell, that does work, so I'm getting to manage.py OK.

I've been spinning my wheels on this one for a while, and webfaction hasn't been much help. Any help is greatly appreciated. Thanks!


Solution

  • I made a rookie mistake and completely left out some of the necessary structure for a django command task:

    class Command(BaseCommand): 
    help = 'Deletes expired legs, preferences and assignments' 
        def handle(self, *args, **options):