Agenda: Can't schedule yearly jobs with cron

Created on 13 Aug 2019  路  4Comments  路  Source: agenda/agenda

Hello,

I'm trying to create a job that is supposed to repeat once a year on a specific date.
My cron interval looks like this: 0 16 13 8 *
Once the job is executed its nextRunAt is set not a year later but a month later.

Here's how I schedule the job

        this._agenda.jobs({name: jobId}, (err, job1) => {
            if (job1 && job1.length === 0) {
                this._agenda.define('someJobId', (job: Agenda.Job, done: (err?: Error) => void) => {
                    this._doJobs('someJobId', job, done).then().catch(e => {
                        Promise.reject(e);
                    });
                });
                let job = this._agenda.create(jobId, jobInfo)
                    .schedule(new Date())
                    .repeatEvery('0 16 13 8 *', {
                        timezone: 'America/Toronto',
                        skipImmediate: true
                    });
                job.save();
            } else if (!err) { /* print error message */ });

And here's how it looks like in mongo after it's executed once:
image

I could be missing something obvious and would appreciate your help.

Thank you

Most helpful comment

This seems to be the same as this issue https://github.com/agenda/agenda/issues/358 ...

from 2016!

I would think this would be an extremely high priority issue since this is base functionality. Do we know if a fix is in progress or expected soon?

All 4 comments

That's because 0 16 13 8 * is At 16:00 on day-of-month 13 in August
https://crontab.guru/#0_16_13_8_*

EDIT: never mind. you might be right. what happens if you remove the skipImmediate: true?

Tried without skipImmediate: true. nextRunAt is set on the same day and time of the next month
The following is after the "yearly" job has ran once
image

This seems to be the same as this issue https://github.com/agenda/agenda/issues/358 ...

from 2016!

I would think this would be an extremely high priority issue since this is base functionality. Do we know if a fix is in progress or expected soon?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

niftylettuce picture niftylettuce  路  6Comments

stefan0001 picture stefan0001  路  3Comments

exislow picture exislow  路  5Comments

bankzxcv picture bankzxcv  路  3Comments

mKontakis picture mKontakis  路  3Comments