Celery每秒执行一次任务,每年一次crontab

时间:2013-07-05 14:26:21

标签: django celery djcelery

我试图让任务在1/1结束时运行。所以,我写了这个:

@periodic_task(run_every = crontab(
    day_of_month=1, month_of_year=1, hour=23, minute=51)
)
def tell_admins_about_completed_updates():
    logging.info('Updates to period instances are complete', extra={
            'tell_admins': True,
            'email_content': 'Please check that new instances are displaying '
                'properly'
        }
    )

使用crontab,我看到这个任务每秒都在运行。如果我将小时值更改为0,我就不会看到它执行(大概是因为它不是正确的时间)。还有其他人观察过这种行为吗?我错过了一些基本的东西吗?

编辑:我再次检查。如果我按照上面的建议更改month_of_year(不是hour),行为似乎会发生变化。要明确的是,如果crontab配置了day_of_month=31, month_of_year=12, hour=0, minute=49,它似乎可以工作(即,我没有看到每秒运行的任务)。如果crontab配置了day_of_month=31, month_of_year=1, hour=0, minute=49,它就不起作用(即,我看到任务每秒都在运行)。很奇怪......

0 个答案:

没有答案