[Django]-Celery periodic tasks once in 2 weeks

4👍

to my knowledge, this couldn’t be done solely with crontab

first, make your task run on every Sunday night:

crontab(minute=0, hour=0, day_of_week='sunday')

then, in your task function, check if the week number is even, if so, do nothing:

from datetime import datetime

week_number = int(datetime.today().strftime("%U"))    
if week_number % 2 == 0:
    return

Leave a comment