Set up a scheduled job?

后端 未结 24 2490
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 01:13

I\'ve been working on a web app using Django, and I\'m curious if there is a way to schedule a job to run periodically.

Basically I just want to run through the dat

24条回答
  •  爱一瞬间的悲伤
    2020-11-22 02:05

    Put the following at the top of your cron.py file:

    #!/usr/bin/python
    import os, sys
    sys.path.append('/path/to/') # the parent directory of the project
    sys.path.append('/path/to/project') # these lines only needed if not on path
    os.environ['DJANGO_SETTINGS_MODULE'] = 'myproj.settings'
    
    # imports and code below
    

提交回复
热议问题