Kevin Ramirez Zavalza
Kevin Ramirez Zavalza

Reputation: 1785

Run cron based on Django Datefield/Datetimefield?

I hope you can help me, I was wondering if there's any way to run a cron based on a stored value in Datefield or Datetimefield in django?

Maybe with the use of a module?

I was thinking to store the time in increments of 15 minutes, and then run my cron every day 15 minutes, and then check if the time matches.

e.g.

Store if my object the datetimefield with 10/09/2017 (dd/mm/yyyy) and 13:00 or 13:15 or 13:30 ....

Then every 15 minutes my cron runs a django management command and with it make a filter to get all the objects with a matching datetime and if exist(using a datetime.now maybe to get the cron date and time when it's executed), and then perform another action.

Maybe this I'm taking the wrong course to solve this, I hope you can help me.

Upvotes: 0

Views: 319

Answers (1)

Krzysztof Szularz
Krzysztof Szularz

Reputation: 5249

Don't go that path.

Rather just use Celery. It's built just for such use cases.

http://docs.celeryproject.org/en/latest/userguide/periodic-tasks.html

Upvotes: 1

Related Questions