I'm scheduling a job using this code:
var job = global.agenda.create('send happy hour notification', {});
job.repeatEvery('0 21 * * *');
job.unique({});
job.save();
So the job should run everyday at 21:00.
But every time I run my app it runs this job..
Am I doing something wrong?
If you run a job.computeNextRunAt(); after setting the repeat interval, it should set the next run time correctly.
@jakeorr Thanks! Seems like it works..
@jakeorr Shouldn't this be the default or at least an option when creating a job?
@bvallelunga I didn't write this code so I'm not sure what the thinking was. It may have been intentional to always have the job run immediately on creation. If you have a better way to do it, you could submit a PR.
Follow ups https://github.com/agenda/agenda/issues/422
Most helpful comment
@jakeorr Thanks! Seems like it works..