我有一个函数来执行cron作业,代码如下:
def add_config_job(sched, job):
module = JOB_METHODS.get(job["type"])
if module is None:
logging.warn("job type %r not supported", job["type"])
return
func = module.cron_job
args = (job,)
name = "%s__%s" % (job["name"], job["id"])
start_date = job.get("start_date")
run_at = job["run_at"]
if isinstance(job["run_at"], dict):
sched.add_cron_job(func, args=args, name=name, start_date=start_date,
**run_at)
elif isinstance(job["run_at"], basestring):
sched.add_date_job(func, args=args, name=name, date=run_at)
else:
logging.warn("unsupported 'run_at' type (%s given)", run_at)
我得到了错过了一些秒数的错过工作的错误。
2015-05-14_00:00:02.76629 WARNING: Run time of job "Daily VPN Connexion__1 (trigger: cron[day='*', hour='0', minute='0', second='0'], next run at: 2015-05-14 00:00:00)" was missed by 0:00:02.493426
2015-05-14_00:00:02.79309 WARNING: Run time of job "Daily Report VPN Connection ALIGRO__1 (trigger: cron[day='*', hour='0', minute='0', second='0'], next run at: 2015-05-14 00:00:00)" was missed by 0:00:02.777450
这个工作失灵的原因是什么?我们如何避免它发生? 在一些页面上,我发现将misfire_grace_time从默认值1秒增加。调度程序不应该在适当的时间内安排而不错过它吗?