0

I'm searching for a method to make a def to execute at a time value when I run the server... Example once per day. One solution is to use Celery but i don't want to use it only for a simple def... Any suggestion? I'm using windows. Thanks!

Florin
  • 292
  • 2
  • 13

2 Answers2

0

There are certainly several possibilities, so this is just one of many solutions:

We use Unix cron jobs or Kubernetes cron jobs for this which call:

./manage.py <the command>

(or call docker exec .... manage.py <the command>)

You should make sure that your logs go whereever you need them to monitor the cron job.

Note: there was a similar question I've answered with more details: https://stackoverflow.com/a/52778625/621690

Risadinha
  • 16,058
  • 2
  • 88
  • 91
0

Look in to using the Windows Task Scheduler to run your django task via manage.py. You can schedule it once a day from here or as often as you need.

https://learn.microsoft.com/en-us/windows/win32/taskschd/task-scheduler-start-page

Use the simplest solution to solve your problem until you require a more complex solution.

Josh J
  • 6,813
  • 3
  • 25
  • 47